Make migrations async

This commit is contained in:
Mo Bitar
2019-01-10 12:35:46 -06:00
parent 42ec6ee9bb
commit 3f055f5672
3 changed files with 12 additions and 7 deletions

View File

@@ -21,7 +21,7 @@ class MigrationManager extends SFMigrationManager {
return {
name: "editor-to-component",
content_type: "SN|Editor",
handler: (editors) => {
handler: async (editors) => {
// Convert editors to components
for(var editor of editors) {
// If there's already a component for this url, then skip this editor
@@ -60,7 +60,8 @@ class MigrationManager extends SFMigrationManager {
return {
name: "component-url-to-hosted-url",
content_type: "SN|Component",
handler: (components) => {
handler: async (components) => {
let hasChanges = false;
var notes = this.modelManager.validItemsForContentType("Note");
for(var note of notes) {
for(var component of components) {
@@ -69,10 +70,14 @@ class MigrationManager extends SFMigrationManager {
note.setDomainDataItem(component.uuid, clientData, ComponentManager.ClientDataDomain);
note.setDomainDataItem(component.hosted_url, null, ComponentManager.ClientDataDomain);
note.setDirty(true, true); // dont update client date
hasChanges = true;
}
}
}
this.syncManager.sync();
if(hasChanges) {
this.syncManager.sync();
}
}
}
}