mirror of
https://github.com/Foundry376/Mailspring.git
synced 2024-11-12 04:25:31 +08:00
f413386b80
Summary: By default, the messages in a thread are now filtered to exclude ones moved to trash or spam. You can choose to view those messages by clicking the new bar in the message list. When you view your spam or trash, we only show the messages on those threads that have been marked as spam/trash. Test Plan: Run a couple new tests Reviewers: juan, evan Reviewed By: evan Differential Revision: https://phab.nylas.com/D2662
64 lines
1.7 KiB
JavaScript
64 lines
1.7 KiB
JavaScript
import {
|
|
React,
|
|
Actions,
|
|
MessageStore,
|
|
FocusedPerspectiveStore,
|
|
} from 'nylas-exports';
|
|
|
|
export default class MessageListHiddenMessagesToggle extends React.Component {
|
|
|
|
static displayName = 'MessageListHiddenMessagesToggle';
|
|
|
|
constructor() {
|
|
super();
|
|
this.state = {
|
|
numberOfHiddenItems: MessageStore.numberOfHiddenItems(),
|
|
};
|
|
}
|
|
|
|
componentDidMount() {
|
|
this._unlisten = MessageStore.listen(() => {
|
|
this.setState({
|
|
numberOfHiddenItems: MessageStore.numberOfHiddenItems(),
|
|
});
|
|
});
|
|
}
|
|
|
|
componentWillUnmount() {
|
|
this._unlisten();
|
|
}
|
|
|
|
render() {
|
|
const {numberOfHiddenItems} = this.state;
|
|
if (numberOfHiddenItems === 0) {
|
|
return false;
|
|
}
|
|
|
|
|
|
const viewing = FocusedPerspectiveStore.current().categoriesSharedName();
|
|
let message = null;
|
|
|
|
if (MessageStore.CategoryNamesHiddenByDefault.includes(viewing)) {
|
|
if (numberOfHiddenItems > 1) {
|
|
message = `There are ${numberOfHiddenItems} more messages in this thread that are not in spam or trash.`;
|
|
} else {
|
|
message = `There is one more message in this thread that is not in spam or trash.`;
|
|
}
|
|
} else {
|
|
if (numberOfHiddenItems > 1) {
|
|
message = `${numberOfHiddenItems} messages in this thread are hidden because it was moved to trash or spam.`;
|
|
} else {
|
|
message = `One message in this thread is hidden because it was moved to trash or spam.`;
|
|
}
|
|
}
|
|
|
|
return (
|
|
<div className="show-hidden-messages">
|
|
{message}
|
|
<a onClick={function toggle() { Actions.toggleHiddenMessages() }}>Show all messages</a>
|
|
</div>
|
|
);
|
|
}
|
|
}
|
|
|
|
MessageListHiddenMessagesToggle.containerRequired = false;
|