mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-10-06 19:26:55 +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": {
|
"windowTypes": {
|
||||||
"default": true,
|
"default": true,
|
||||||
"composer": true
|
"composer": true,
|
||||||
|
"composer-preload": true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -299,10 +299,20 @@ class DraftStore
|
||||||
|
|
||||||
_onHandleMailFiles: (event, paths) =>
|
_onHandleMailFiles: (event, paths) =>
|
||||||
DraftFactory.createDraft().then (draft) =>
|
DraftFactory.createDraft().then (draft) =>
|
||||||
@_finalizeAndPersistNewMessage(draft, popout: true)
|
@_finalizeAndPersistNewMessage(draft)
|
||||||
.then ({draftClientId}) =>
|
.then ({draftClientId}) =>
|
||||||
|
remaining = paths.length
|
||||||
|
callback = =>
|
||||||
|
remaining -= 1
|
||||||
|
if remaining is 0
|
||||||
|
@_onPopoutDraftClientId(draftClientId)
|
||||||
|
|
||||||
for path in paths
|
for path in paths
|
||||||
Actions.addAttachment({filePath: path, messageClientId: draftClientId})
|
Actions.addAttachment({
|
||||||
|
filePath: path,
|
||||||
|
messageClientId: draftClientId,
|
||||||
|
callback: callback
|
||||||
|
})
|
||||||
|
|
||||||
_onDestroyDraft: (draftClientId) =>
|
_onDestroyDraft: (draftClientId) =>
|
||||||
session = @_draftSessions[draftClientId]
|
session = @_draftSessions[draftClientId]
|
||||||
|
|
|
@ -59,7 +59,9 @@ class FileUploadStore extends NylasStore
|
||||||
pathsToOpen.forEach (filePath) ->
|
pathsToOpen.forEach (filePath) ->
|
||||||
Actions.addAttachment({messageClientId, filePath})
|
Actions.addAttachment({messageClientId, filePath})
|
||||||
|
|
||||||
_onAddAttachment: ({messageClientId, filePath}) ->
|
_onAddAttachment: ({messageClientId, filePath, callback}) ->
|
||||||
|
callback ?= ->
|
||||||
|
|
||||||
@_verifyId(messageClientId)
|
@_verifyId(messageClientId)
|
||||||
@_getFileStats({messageClientId, filePath})
|
@_getFileStats({messageClientId, filePath})
|
||||||
.then(@_makeUpload)
|
.then(@_makeUpload)
|
||||||
|
@ -69,6 +71,7 @@ class FileUploadStore extends NylasStore
|
||||||
.then (upload) =>
|
.then (upload) =>
|
||||||
@_applySessionChanges upload.messageClientId, (uploads) ->
|
@_applySessionChanges upload.messageClientId, (uploads) ->
|
||||||
uploads.concat([upload])
|
uploads.concat([upload])
|
||||||
|
.then(callback)
|
||||||
.catch(@_onAttachFileError)
|
.catch(@_onAttachFileError)
|
||||||
|
|
||||||
_onRemoveAttachment: (upload) ->
|
_onRemoveAttachment: (upload) ->
|
||||||
|
@ -145,10 +148,4 @@ class FileUploadStore extends NylasStore
|
||||||
uploads = changeFunction(session.draft().uploads)
|
uploads = changeFunction(session.draft().uploads)
|
||||||
session.changes.add({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()
|
module.exports = new FileUploadStore()
|
||||||
|
|
Loading…
Add table
Reference in a new issue