mirror of
https://github.com/Foundry376/Mailspring.git
synced 2024-11-11 01:54:40 +08:00
fix(labels/folders): Temporarily disable changing nested messages
- It's slow, and causes performLocal to take much longer - It's making changes we receive from the streaming API a few moments later - We don't actually display nested folder data anywhere important
This commit is contained in:
parent
be4af0671b
commit
5e39454ad9
4 changed files with 30 additions and 15 deletions
|
@ -103,11 +103,13 @@ describe "ChangeMailTask", ->
|
|||
expect(@task._applyChanges).toHaveBeenCalledWith(@task.threads)
|
||||
expect(DatabaseStore.persistModels).toHaveBeenCalledWith([@threadAChanged])
|
||||
|
||||
it "fetches messages on changed threads and appends them to the messages to update", ->
|
||||
waitsForPromise =>
|
||||
@task._performLocalThreads().then =>
|
||||
expect(@task._applyChanges).toHaveBeenCalledWith(@task.threads)
|
||||
expect(@task.messages).toEqual([@threadAMesage1, @threadAMesage2])
|
||||
describe "when _processesNestedMessages is overridden to return true", ->
|
||||
it "fetches messages on changed threads and appends them to the messages to update", ->
|
||||
waitsForPromise =>
|
||||
@task._processesNestedMessages = => true
|
||||
@task._performLocalThreads().then =>
|
||||
expect(@task._applyChanges).toHaveBeenCalledWith(@task.threads)
|
||||
expect(@task.messages).toEqual([@threadAMesage1, @threadAMesage2])
|
||||
|
||||
describe "_performLocalMessages", ->
|
||||
beforeEach ->
|
||||
|
|
|
@ -65,6 +65,9 @@ class ChangeFolderTask extends ChangeMailTask
|
|||
# The base class does the heavy lifting and calls _changesToModel
|
||||
return super
|
||||
|
||||
_processesNestedMessages: ->
|
||||
false
|
||||
|
||||
_changesToModel: (model) ->
|
||||
if model instanceof Thread
|
||||
{folders: [@folder]}
|
||||
|
|
|
@ -59,8 +59,9 @@ class ChangeLabelsTask extends ChangeMailTask
|
|||
# The base class does the heavy lifting and calls _changesToModel
|
||||
return super
|
||||
|
||||
# Returns a new set of {Label} objects that incoprates the existing,
|
||||
# new, and removed labels.
|
||||
_processesNestedMessages: ->
|
||||
false
|
||||
|
||||
_changesToModel: (model) ->
|
||||
labelsToRemoveIds = _.pluck(@labelsToRemove, 'id')
|
||||
|
||||
|
|
|
@ -18,12 +18,7 @@ NamespaceStore = require '../stores/namespace-store'
|
|||
# ChangeMailTask stores the previous values of all models it changes into @_restoreValues
|
||||
# and handles undo/redo. When undoing, it restores previous values and calls
|
||||
# `_requestBodyForModel` to make undo API requests. It does not call `_changesToModel`.
|
||||
#
|
||||
# Generally, you cannot provide both messages and threads at the same time. However,
|
||||
# ChangeMailTask runs for provided `threads` first, so your subclass can populate
|
||||
# @messages with the messages of those threads to make adjustments to them.
|
||||
# API requests are only made for threads if threads are present.
|
||||
#
|
||||
##
|
||||
class ChangeMailTask extends Task
|
||||
|
||||
constructor: ({@threads, thread, @messages, message} = {}) ->
|
||||
|
@ -48,6 +43,17 @@ class ChangeMailTask extends Task
|
|||
_requestBodyForModel: (model) ->
|
||||
throw new Error("You must override this method.")
|
||||
|
||||
# Generally, you cannot provide both messages and threads at the same time. However,
|
||||
# ChangeMailTask runs for provided threads first and then messages. Override
|
||||
# and return true, and you will receive `_changesToModel` for messages in
|
||||
# changed threads, and any changes you make will be written to the database
|
||||
# and undone during undo.
|
||||
#
|
||||
# Note that API requests are only made for threads if threads are present.
|
||||
#
|
||||
_processesNestedMessages: ->
|
||||
false
|
||||
|
||||
# Perform Local
|
||||
|
||||
# Subclasses should override `performLocal` and call super once they've
|
||||
|
@ -72,8 +78,11 @@ class ChangeMailTask extends Task
|
|||
changedIds = _.pluck(changed, 'id')
|
||||
|
||||
DatabaseStore.persistModels(changed).then =>
|
||||
DatabaseStore.findAll(Message).where(Message.attributes.threadId.in(changedIds)).then (messages) =>
|
||||
@messages = [].concat(messages, @messages)
|
||||
if @_processesNestedMessages()
|
||||
DatabaseStore.findAll(Message).where(Message.attributes.threadId.in(changedIds)).then (messages) =>
|
||||
@messages = [].concat(messages, @messages)
|
||||
Promise.resolve()
|
||||
else
|
||||
Promise.resolve()
|
||||
|
||||
_performLocalMessages: ->
|
||||
|
|
Loading…
Reference in a new issue