mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-02-23 23:54:13 +08:00
fix(tracking): Calling Actions.setMetadata from applyTransforms no longer works
This commit is contained in:
parent
b9f39cd86e
commit
65a60f2d96
3 changed files with 32 additions and 26 deletions
|
@ -381,13 +381,15 @@ class DraftStore
|
||||||
# Run draft transformations registered by third-party plugins
|
# Run draft transformations registered by third-party plugins
|
||||||
allowedFields = ['to', 'from', 'cc', 'bcc', 'subject', 'body']
|
allowedFields = ['to', 'from', 'cc', 'bcc', 'subject', 'body']
|
||||||
|
|
||||||
|
session.changes.commit(noSyncback: true).then =>
|
||||||
|
draft = session.draft().clone()
|
||||||
|
|
||||||
Promise.each @extensions(), (ext) ->
|
Promise.each @extensions(), (ext) ->
|
||||||
extApply = ext.applyTransformsToDraft
|
extApply = ext.applyTransformsToDraft
|
||||||
extUnapply = ext.unapplyTransformsToDraft
|
extUnapply = ext.unapplyTransformsToDraft
|
||||||
unless extApply and extUnapply
|
unless extApply and extUnapply
|
||||||
return Promise.resolve()
|
return Promise.resolve()
|
||||||
|
|
||||||
draft = session.draft().clone()
|
|
||||||
Promise.resolve(extUnapply({draft})).then (cleaned) =>
|
Promise.resolve(extUnapply({draft})).then (cleaned) =>
|
||||||
cleaned = draft if cleaned is 'unnecessary'
|
cleaned = draft if cleaned is 'unnecessary'
|
||||||
Promise.resolve(extApply({draft: cleaned})).then (transformed) =>
|
Promise.resolve(extApply({draft: cleaned})).then (transformed) =>
|
||||||
|
@ -402,10 +404,11 @@ class DraftStore
|
||||||
console.log("-- UNTRANSFORMED (should match BEFORE) --")
|
console.log("-- UNTRANSFORMED (should match BEFORE) --")
|
||||||
console.log(untransformed.body)
|
console.log(untransformed.body)
|
||||||
NylasEnv.reportError(new Error("An extension applied a tranform to the draft that it could not reverse."))
|
NylasEnv.reportError(new Error("An extension applied a tranform to the draft that it could not reverse."))
|
||||||
session.changes.add(_.pick(transformed, allowedFields))
|
draft = transformed
|
||||||
|
|
||||||
.then =>
|
.then =>
|
||||||
session.changes.commit(noSyncback: true)
|
DatabaseStore.inTransaction (t) =>
|
||||||
|
t.persistModel(draft)
|
||||||
|
|
||||||
_onRemoveFile: ({file, messageClientId}) =>
|
_onRemoveFile: ({file, messageClientId}) =>
|
||||||
@sessionForClientId(messageClientId).then (session) ->
|
@sessionForClientId(messageClientId).then (session) ->
|
||||||
|
|
2
src/pro
2
src/pro
|
@ -1 +1 @@
|
||||||
Subproject commit 1c66da339a724a1562354e07433170033f5c8638
|
Subproject commit ec04ee3f59272cfa5de87ff465b2e675eafa19ad
|
|
@ -42,12 +42,12 @@ class WindowEventHandler
|
||||||
ipcRenderer.on 'scroll-touch-end', ->
|
ipcRenderer.on 'scroll-touch-end', ->
|
||||||
window.dispatchEvent(new Event('scroll-touch-end'))
|
window.dispatchEvent(new Event('scroll-touch-end'))
|
||||||
|
|
||||||
window.addEventListener 'beforeunload', =>
|
window.onbeforeunload = =>
|
||||||
# Don't hide the window here if we don't want the renderer process to be
|
# Don't hide the window here if we don't want the renderer process to be
|
||||||
# throttled in case more work needs to be done before closing
|
# throttled in case more work needs to be done before closing
|
||||||
return @runUnloadCallbacks()
|
return @runUnloadCallbacks()
|
||||||
|
|
||||||
window.addEventListener 'unload', =>
|
window.onunload = =>
|
||||||
NylasEnv.storeWindowDimensions()
|
NylasEnv.storeWindowDimensions()
|
||||||
NylasEnv.saveStateAndUnloadWindow()
|
NylasEnv.saveStateAndUnloadWindow()
|
||||||
|
|
||||||
|
@ -108,10 +108,12 @@ class WindowEventHandler
|
||||||
@unloadCallbacks.push(callback)
|
@unloadCallbacks.push(callback)
|
||||||
|
|
||||||
runUnloadCallbacks: ->
|
runUnloadCallbacks: ->
|
||||||
|
hasReturned = false
|
||||||
|
|
||||||
unloadCallbacksRunning = 0
|
unloadCallbacksRunning = 0
|
||||||
unloadCallbackComplete = =>
|
unloadCallbackComplete = =>
|
||||||
unloadCallbacksRunning -= 1
|
unloadCallbacksRunning -= 1
|
||||||
if unloadCallbacksRunning is 0
|
if unloadCallbacksRunning is 0 and hasReturned
|
||||||
@runUnloadFinished()
|
@runUnloadFinished()
|
||||||
|
|
||||||
for callback in @unloadCallbacks
|
for callback in @unloadCallbacks
|
||||||
|
@ -122,6 +124,7 @@ class WindowEventHandler
|
||||||
console.warn "You registered an `onBeforeUnload` callback that does not return either exactly `true` or `false`. It returned #{returnValue}", callback
|
console.warn "You registered an `onBeforeUnload` callback that does not return either exactly `true` or `false`. It returned #{returnValue}", callback
|
||||||
|
|
||||||
# In Electron, returning false cancels the close.
|
# In Electron, returning false cancels the close.
|
||||||
|
hasReturned = true
|
||||||
return (unloadCallbacksRunning is 0)
|
return (unloadCallbacksRunning is 0)
|
||||||
|
|
||||||
runUnloadFinished: ->
|
runUnloadFinished: ->
|
||||||
|
|
Loading…
Reference in a new issue