From 3f055f56728b80da599b44672bc8752fed021cf6 Mon Sep 17 00:00:00 2001 From: Mo Bitar Date: Thu, 10 Jan 2019 12:35:46 -0600 Subject: [PATCH] Make migrations async --- .../javascripts/app/services/migrationManager.js | 11 ++++++++--- package-lock.json | 6 +++--- package.json | 2 +- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/app/assets/javascripts/app/services/migrationManager.js b/app/assets/javascripts/app/services/migrationManager.js index d6d522203..66f52bca8 100644 --- a/app/assets/javascripts/app/services/migrationManager.js +++ b/app/assets/javascripts/app/services/migrationManager.js @@ -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(); + } } } } diff --git a/package-lock.json b/package-lock.json index e16072f11..0d5f759be 100644 --- a/package-lock.json +++ b/package-lock.json @@ -8097,9 +8097,9 @@ "dev": true }, "standard-file-js": { - "version": "0.3.22", - "resolved": "https://registry.npmjs.org/standard-file-js/-/standard-file-js-0.3.22.tgz", - "integrity": "sha512-nezAUHLX0K0DVtdofrWv2wuznXD8xPJLC/F/usGqtxvtqWbpH+MG99WtHidOd3D38qlGY7PER1nRbFT0WbA92w==", + "version": "0.3.31", + "resolved": "https://registry.npmjs.org/standard-file-js/-/standard-file-js-0.3.31.tgz", + "integrity": "sha512-flbgmQWrLJQ2TAv+RZkVG23akePixAqekAvG8yNEyueR5E/Fdtgm2LFEbg2sFf+ko/qR0vqWgq95cgUdTejRQA==", "dev": true }, "static-extend": { diff --git a/package.json b/package.json index 4348a6afd..6ae9c4e19 100644 --- a/package.json +++ b/package.json @@ -45,7 +45,7 @@ "serve-static": "^1.13.2", "sn-models": "0.1.9", "sn-stylekit": "2.0.13", - "standard-file-js": "0.3.22", + "standard-file-js": "0.3.31", "grunt-shell": "^2.1.0" } }