From 33172ed342b7880528f1c2539e297637b8e6e3b1 Mon Sep 17 00:00:00 2001 From: Ben Gotow Date: Thu, 19 Oct 2017 14:25:33 -0700 Subject: [PATCH] Correctly convert new folder/label names to UTF7 --- .../account-sidebar/lib/sidebar-item.coffee | 6 +++--- .../lib/sidebar-section.coffee | 4 ++-- .../lib/label-picker-popover.jsx | 4 ++-- .../lib/move-picker-popover.jsx | 4 ++-- app/src/flux/tasks/syncback-category-task.es6 | 19 ++++++++++++++----- 5 files changed, 23 insertions(+), 14 deletions(-) diff --git a/app/internal_packages/account-sidebar/lib/sidebar-item.coffee b/app/internal_packages/account-sidebar/lib/sidebar-item.coffee index b4c11ca93..6a5820298 100644 --- a/app/internal_packages/account-sidebar/lib/sidebar-item.coffee +++ b/app/internal_packages/account-sidebar/lib/sidebar-item.coffee @@ -65,10 +65,10 @@ onEditItem = (item, value) -> if newDisplayName is category.displayName return - Actions.queueTask(new SyncbackCategoryTask({ + Actions.queueTask(SyncbackCategoryTask.forRenaming({ accountId: category.accountId, - existingPath: category.path, - path: newDisplayName, + path: category.path, + newName: newDisplayName, })) diff --git a/app/internal_packages/account-sidebar/lib/sidebar-section.coffee b/app/internal_packages/account-sidebar/lib/sidebar-section.coffee index e02a5e158..390e58664 100644 --- a/app/internal_packages/account-sidebar/lib/sidebar-section.coffee +++ b/app/internal_packages/account-sidebar/lib/sidebar-section.coffee @@ -183,8 +183,8 @@ class SidebarSection onCollapseToggled: onCollapseToggled onItemCreated: (displayName) -> return unless displayName - Actions.queueTask(new SyncbackCategoryTask({ - path: displayName, + Actions.queueTask(SyncbackCategoryTask.forCreating({ + name: displayName, accountId: account.id, })) } diff --git a/app/internal_packages/category-picker/lib/label-picker-popover.jsx b/app/internal_packages/category-picker/lib/label-picker-popover.jsx index 1917ec446..9ebb25dfa 100644 --- a/app/internal_packages/category-picker/lib/label-picker-popover.jsx +++ b/app/internal_packages/category-picker/lib/label-picker-popover.jsx @@ -99,8 +99,8 @@ export default class LabelPickerPopover extends Component { if (threads.length === 0) return; if (item.newCategoryItem) { - const syncbackTask = new SyncbackCategoryTask({ - path: this.state.searchValue, + const syncbackTask = SyncbackCategoryTask.forCreating({ + name: this.state.searchValue, accountId: account.id, }); diff --git a/app/internal_packages/category-picker/lib/move-picker-popover.jsx b/app/internal_packages/category-picker/lib/move-picker-popover.jsx index 2facddb82..aa02a6547 100644 --- a/app/internal_packages/category-picker/lib/move-picker-popover.jsx +++ b/app/internal_packages/category-picker/lib/move-picker-popover.jsx @@ -129,8 +129,8 @@ export default class MovePickerPopover extends Component { }; _onCreateCategory = () => { - const syncbackTask = new SyncbackCategoryTask({ - path: this.state.searchValue, + const syncbackTask = SyncbackCategoryTask.forCreating({ + name: this.state.searchValue, accountId: this.props.account.id, }); diff --git a/app/src/flux/tasks/syncback-category-task.es6 b/app/src/flux/tasks/syncback-category-task.es6 index aa2de95d2..48ad8b6fd 100644 --- a/app/src/flux/tasks/syncback-category-task.es6 +++ b/app/src/flux/tasks/syncback-category-task.es6 @@ -1,3 +1,4 @@ +import utf7 from 'utf7'; import Task from './task'; import Attributes from '../attributes'; @@ -14,11 +15,19 @@ export default class SyncbackCategoryTask extends Task { }), }); - constructor({ existingPath, path, accountId, ...rest } = {}) { - super(rest); - this.existingPath = existingPath; - this.path = path; - this.accountId = accountId; + static forCreating({ name, accountId }) { + return new SyncbackCategoryTask({ + path: utf7.imap.encode(name), + accountId: accountId, + }); + } + + static forRenaming({ path, accountId, newName }) { + return new SyncbackCategoryTask({ + existingPath: path, + path: utf7.imap.encode(newName), + accountId: accountId, + }); } label() {