diff --git a/app/internal_packages/category-mapper/lib/category-selection.tsx b/app/internal_packages/category-mapper/lib/category-selection.tsx index 5bd6a515b..2d73be1f2 100644 --- a/app/internal_packages/category-mapper/lib/category-selection.tsx +++ b/app/internal_packages/category-mapper/lib/category-selection.tsx @@ -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'); diff --git a/app/internal_packages/category-mapper/lib/preferences-category-mapper.tsx b/app/internal_packages/category-mapper/lib/preferences-category-mapper.tsx index 291fcf8b0..b54891d5c 100644 --- a/app/internal_packages/category-mapper/lib/preferences-category-mapper.tsx +++ b/app/internal_packages/category-mapper/lib/preferences-category-mapper.tsx @@ -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 (
{Category.LocalizedStringForRole[role]}:
this._onCategorySelection(account, role, category)} - accountUsesLabels={account.usesLabels()} + allowLabels={allowLabels} />
diff --git a/app/src/mailbox-perspective.ts b/app/src/mailbox-perspective.ts index 3c691ec49..592643060 100644 --- a/app/src/mailbox-perspective.ts +++ b/app/src/mailbox-perspective.ts @@ -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) => {