mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-02-22 15:15:12 +08:00
Sentry fix: Don’t allow labels to be selected as the Gmail trash folder, see description
This is neat but Gmail has very specific semantics around labels vs the “spam”, “trash” and “all mail” folders. If you choose a label as your Trash the email still appears in all mail and Mailspring freaks out in several places. We could fix support for this scenarrio, but it’s unlikely this is what users actually want.
This commit is contained in:
parent
1c485ae213
commit
0134c8a4b3
3 changed files with 18 additions and 12 deletions
|
@ -9,7 +9,7 @@ import {
|
|||
import { localized, Label, Utils, PropTypes } from 'mailspring-exports';
|
||||
|
||||
interface CategorySelectionProps {
|
||||
accountUsesLabels: boolean;
|
||||
allowLabels: boolean;
|
||||
all: CategoryItem[];
|
||||
current: CategoryItem;
|
||||
onSelect: (item: CategoryItem) => void;
|
||||
|
@ -31,7 +31,7 @@ export default class CategorySelection extends React.Component<
|
|||
CategorySelectionState
|
||||
> {
|
||||
static propTypes = {
|
||||
accountUsesLabels: PropTypes.bool,
|
||||
allowLabels: PropTypes.bool,
|
||||
all: PropTypes.array,
|
||||
current: PropTypes.object,
|
||||
onSelect: PropTypes.func,
|
||||
|
@ -95,7 +95,7 @@ export default class CategorySelection extends React.Component<
|
|||
};
|
||||
|
||||
render() {
|
||||
const placeholder = this.props.accountUsesLabels
|
||||
const placeholder = this.props.allowLabels
|
||||
? localized('Choose folder or label')
|
||||
: localized('Choose folder');
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@ import {
|
|||
Category,
|
||||
Actions,
|
||||
ChangeRoleMappingTask,
|
||||
Folder,
|
||||
} from 'mailspring-exports';
|
||||
|
||||
import CategorySelection from './category-selection';
|
||||
|
@ -79,15 +80,20 @@ export default class PreferencesCategoryMapper extends React.Component<{}, State
|
|||
if (account.provider === 'gmail' && role === 'archive') {
|
||||
return false;
|
||||
}
|
||||
|
||||
let all = this.state.all[account.id];
|
||||
const allowLabels = account.usesLabels() && role !== 'trash' && role !== 'spam';
|
||||
if (!allowLabels) all = all.filter(c => c instanceof Folder);
|
||||
|
||||
return (
|
||||
<div className="role-section" key={`${account.id}-${role}`}>
|
||||
<div className="col-left">{Category.LocalizedStringForRole[role]}:</div>
|
||||
<div className="col-right">
|
||||
<CategorySelection
|
||||
all={this.state.all[account.id]}
|
||||
all={all}
|
||||
current={assignments[role]}
|
||||
onSelect={category => this._onCategorySelection(account, role, category)}
|
||||
accountUsesLabels={account.usesLabels()}
|
||||
allowLabels={allowLabels}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -536,15 +536,15 @@ class CategoryMailboxPerspective extends MailboxPerspective {
|
|||
ChangeFolderTask =
|
||||
ChangeFolderTask || require('./flux/tasks/change-folder-task').ChangeFolderTask;
|
||||
|
||||
// TODO this is an awful hack
|
||||
const role = this.isArchive() ? 'archive' : this.categoriesSharedRole();
|
||||
|
||||
if (role === 'spam' || role === 'trash') {
|
||||
return [];
|
||||
// If you are viewing the archive, "remove" goes to the trash, since obeying
|
||||
// your rpreference would mean possibly doing nothing (if you default to archive.)
|
||||
if (this.isArchive()) {
|
||||
return TaskFactory.tasksForMovingToTrash({ threads, source });
|
||||
}
|
||||
|
||||
if (role === 'archive') {
|
||||
return TaskFactory.tasksForMovingToTrash({ threads, source });
|
||||
// If you are viewing spam or trash, "remove" does nothing
|
||||
if (['spam', 'trash'].includes(this.categoriesSharedRole())) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return TaskFactory.tasksForThreadsByAccountId(threads, (accountThreads, accountId) => {
|
||||
|
|
Loading…
Reference in a new issue