From 75bd2653f7040937b59927bfc8f262493dcba8c3 Mon Sep 17 00:00:00 2001 From: Mo Bitar Date: Thu, 9 Apr 2020 16:23:06 -0500 Subject: [PATCH] Wip --- .../directives/views/componentView.js | 20 ++++++++----------- .../directives/views/revisionPreviewModal.js | 3 +-- .../javascripts/services/themeManager.js | 3 +-- 3 files changed, 10 insertions(+), 16 deletions(-) diff --git a/app/assets/javascripts/directives/views/componentView.js b/app/assets/javascripts/directives/views/componentView.js index 81c2fc3a9..cae0cca94 100644 --- a/app/assets/javascripts/directives/views/componentView.js +++ b/app/assets/javascripts/directives/views/componentView.js @@ -32,13 +32,11 @@ class ComponentViewCtrl { this.unregisterComponentHandler(); this.unregisterComponentHandler = null; if (this.component && !this.manualDealloc) { - const dontSync = true; /* application and componentManager may be destroyed if this onDestroy is part of the entire application being destroyed rather than part of just a single component view being removed */ if (this.application && this.application.componentManager) { - this.application.componentManager - .deactivateComponent(this.component, dontSync); + this.application.componentManager.deregisterComponent(this.component); } } this.unregisterDesktopObserver(); @@ -62,17 +60,14 @@ class ComponentViewCtrl { const newComponent = this.component; const oldComponent = this.lastComponentValue; this.lastComponentValue = newComponent; - const dontSync = true; if (oldComponent && oldComponent !== newComponent) { - this.application.componentManager.deactivateComponent( - oldComponent, - dontSync + this.application.componentManager.deregisterComponent( + oldComponent ); } if (newComponent && newComponent !== oldComponent) { - this.application.componentManager.activateComponent( - newComponent, - dontSync + this.application.componentManager.registerComponent( + newComponent ).then(() => { this.reloadStatus(); }); @@ -136,8 +131,9 @@ class ComponentViewCtrl { } }(); this.expired = component.valid_until && component.valid_until <= new Date(); - if (!component.lockReadonly) { - component.readonly = this.expired; + const readonlyState = this.application.componentManager.getReadonlyStateForComponent(component); + if (!readonlyState.lockReadonly) { + this.application.componentManager.setReadonlyStateForComponent(component, true); } this.componentValid = !offlineRestricted && !hasUrlError; if (!this.componentValid) { diff --git a/app/assets/javascripts/directives/views/revisionPreviewModal.js b/app/assets/javascripts/directives/views/revisionPreviewModal.js index 6529e8406..15a21b092 100644 --- a/app/assets/javascripts/directives/views/revisionPreviewModal.js +++ b/app/assets/javascripts/directives/views/revisionPreviewModal.js @@ -48,8 +48,7 @@ class RevisionPreviewModalCtrl { contentType: ContentTypes.Component, content: editorForNote.content }); - editorCopy.readonly = true; - editorCopy.lockReadonly = true; + this.application.component.setReadonlyStateForComponent(editorCopy, true, true); this.unregisterComponent = this.application.componentManager.registerHandler({ identifier: editorCopy.uuid, areas: ['editor-editor'], diff --git a/app/assets/javascripts/services/themeManager.js b/app/assets/javascripts/services/themeManager.js index 5e90aa62a..3e0e219a5 100644 --- a/app/assets/javascripts/services/themeManager.js +++ b/app/assets/javascripts/services/themeManager.js @@ -80,8 +80,7 @@ export class ThemeManager extends ApplicationService { const activeThemes = this.application.componentManager.getActiveThemes(); for (const theme of activeThemes) { if (theme) { - const dontSync = true; - this.application.componentManager.deactivateComponent(theme, dontSync); + this.application.componentManager.deregisterComponent(theme); } } this.activeThemes = [];