Correctly convert new folder/label names to UTF7

This commit is contained in:
Ben Gotow 2017-10-19 14:25:33 -07:00
parent 3f944f09cf
commit 33172ed342
5 changed files with 23 additions and 14 deletions

View file

@ -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,
}))

View file

@ -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,
}))
}

View file

@ -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,
});

View file

@ -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,
});

View file

@ -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() {