From 5a18196c6d57d4f0a0a66006a509023f94191e6e Mon Sep 17 00:00:00 2001 From: Ben Gotow Date: Thu, 7 Sep 2017 19:16:27 -0700 Subject: [PATCH] Attempt to optimize changeFolderTask can cause it to be invalid --- app/src/flux/tasks/change-folder-task.es6 | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/app/src/flux/tasks/change-folder-task.es6 b/app/src/flux/tasks/change-folder-task.es6 index d6ee4a34f..7e9fc37f6 100644 --- a/app/src/flux/tasks/change-folder-task.es6 +++ b/app/src/flux/tasks/change-folder-task.es6 @@ -32,16 +32,10 @@ export default class ChangeFolderTask extends ChangeMailTask { } if (!data.previousFolders) { data.previousFolders = {}; - } - if (data.threads) { - data.threads = data.threads.filter(t => t.folders.find(f => f.id !== data.folder.id)); - for (const t of data.threads) { - data.previousFolders[t.id] = t.folders.find(f => f.id !== data.folder.id); + for (const t of (data.threads || [])) { + data.previousFolders[t.id] = t.folders.find(f => f.id !== data.folder.id) || t.folders[0]; } - } - if (data.messages) { - data.messages = data.messages.filter(m => m.folder.id !== data.folder.id); - for (const m of data.messages) { + for (const m of (data.messages || [])) { data.previousFolders[m.id] = m.folder; } }