mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-01-24 17:10:07 +08:00
fix(metadata): Correctly call modelify for latest models when setting metadata
This commit is contained in:
parent
b65c4104b4
commit
aedc09b2b3
1 changed files with 5 additions and 1 deletions
|
@ -13,12 +13,16 @@ class MetadataStore extends NylasStore {
|
|||
|
||||
_setMetadata(modelOrModels, pluginId, metadataValue) {
|
||||
const models = (modelOrModels instanceof Array) ? modelOrModels : [modelOrModels];
|
||||
const modelClass = models[0].constructor
|
||||
if (!models.every(m => m.constructor === modelClass)) {
|
||||
throw new Error('Actions.setMetadata - All models provided must be of the same type')
|
||||
}
|
||||
DatabaseStore.inTransaction((t)=> {
|
||||
// Get the latest version of the models from the datbaase before applying
|
||||
// metadata in case other plugins also saved metadata, and we don't want
|
||||
// to overwrite it
|
||||
return (
|
||||
t.modelify(_.pluck(models, 'clientId'))
|
||||
t.modelify(modelClass, _.pluck(models, 'clientId'))
|
||||
.then((latestModels)=> {
|
||||
const updatedModels = latestModels.map(m => m.applyPluginMetadata(pluginId, metadataValue));
|
||||
return (
|
||||
|
|
Loading…
Reference in a new issue