mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-09-20 03:24:38 +08:00
fix(file-drop): Wait for attachments before popping composer
This commit is contained in:
parent
ed27bef1cc
commit
5150dccaf1
3 changed files with 18 additions and 10 deletions
|
@ -12,6 +12,7 @@
|
|||
},
|
||||
"windowTypes": {
|
||||
"default": true,
|
||||
"composer": true
|
||||
"composer": true,
|
||||
"composer-preload": true
|
||||
}
|
||||
}
|
||||
|
|
|
@ -299,10 +299,20 @@ class DraftStore
|
|||
|
||||
_onHandleMailFiles: (event, paths) =>
|
||||
DraftFactory.createDraft().then (draft) =>
|
||||
@_finalizeAndPersistNewMessage(draft, popout: true)
|
||||
@_finalizeAndPersistNewMessage(draft)
|
||||
.then ({draftClientId}) =>
|
||||
remaining = paths.length
|
||||
callback = =>
|
||||
remaining -= 1
|
||||
if remaining is 0
|
||||
@_onPopoutDraftClientId(draftClientId)
|
||||
|
||||
for path in paths
|
||||
Actions.addAttachment({filePath: path, messageClientId: draftClientId})
|
||||
Actions.addAttachment({
|
||||
filePath: path,
|
||||
messageClientId: draftClientId,
|
||||
callback: callback
|
||||
})
|
||||
|
||||
_onDestroyDraft: (draftClientId) =>
|
||||
session = @_draftSessions[draftClientId]
|
||||
|
|
|
@ -59,7 +59,9 @@ class FileUploadStore extends NylasStore
|
|||
pathsToOpen.forEach (filePath) ->
|
||||
Actions.addAttachment({messageClientId, filePath})
|
||||
|
||||
_onAddAttachment: ({messageClientId, filePath}) ->
|
||||
_onAddAttachment: ({messageClientId, filePath, callback}) ->
|
||||
callback ?= ->
|
||||
|
||||
@_verifyId(messageClientId)
|
||||
@_getFileStats({messageClientId, filePath})
|
||||
.then(@_makeUpload)
|
||||
|
@ -69,6 +71,7 @@ class FileUploadStore extends NylasStore
|
|||
.then (upload) =>
|
||||
@_applySessionChanges upload.messageClientId, (uploads) ->
|
||||
uploads.concat([upload])
|
||||
.then(callback)
|
||||
.catch(@_onAttachFileError)
|
||||
|
||||
_onRemoveAttachment: (upload) ->
|
||||
|
@ -145,10 +148,4 @@ class FileUploadStore extends NylasStore
|
|||
uploads = changeFunction(session.draft().uploads)
|
||||
session.changes.add({uploads})
|
||||
|
||||
# In some scenarios (like dropping attachments on the dock icon), files
|
||||
# are added to drafts which may be open in another composer window.
|
||||
# Committing here ensures the files appear immediately, no matter where the
|
||||
# user is now viewing the draft.
|
||||
session.changes.commit()
|
||||
|
||||
module.exports = new FileUploadStore()
|
||||
|
|
Loading…
Add table
Reference in a new issue