Fixes alternateUUID callback, component stack association
This commit is contained in:
@@ -92,7 +92,7 @@ angular.module('app')
|
||||
this.editorForNote = function(note) {
|
||||
let editors = componentManager.componentsForArea("editor-editor");
|
||||
for(var editor of editors) {
|
||||
if(editor.isActiveForItem(note)) {
|
||||
if(editor.isExplicitlyEnabledForItem(note)) {
|
||||
return editor;
|
||||
}
|
||||
}
|
||||
@@ -427,7 +427,7 @@ angular.module('app')
|
||||
}
|
||||
} else {
|
||||
// Editor
|
||||
if(component.active && this.note && (component.isActiveForItem(this.note) || component.isDefaultEditor())) {
|
||||
if(component.active && this.note && (component.isExplicitlyEnabledForItem(this.note) || component.isDefaultEditor())) {
|
||||
this.selectedEditor = component;
|
||||
} else {
|
||||
this.selectedEditor = null;
|
||||
@@ -490,24 +490,23 @@ angular.module('app')
|
||||
|
||||
var stack = componentManager.componentsForArea("editor-stack");
|
||||
for(var component of stack) {
|
||||
var activeForItem = component.isActiveForItem(this.note);
|
||||
if(activeForItem) {
|
||||
if(!component.active) {
|
||||
componentManager.activateComponent(component);
|
||||
}
|
||||
} else {
|
||||
if(component.active) {
|
||||
componentManager.deactivateComponent(component);
|
||||
if(component.active) {
|
||||
var disabledForItem = component.isExplicitlyDisabledForItem(this.note);
|
||||
if(disabledForItem) {
|
||||
component.hidden = true;
|
||||
} else {
|
||||
component.hidden = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.toggleStackComponentForCurrentItem = function(component) {
|
||||
if(component.isActiveForItem(this.note)) {
|
||||
componentManager.deactivateComponent(component);
|
||||
if(component.active) {
|
||||
component.hidden = true;
|
||||
this.disassociateComponentWithCurrentNote(component);
|
||||
} else {
|
||||
// Inactive
|
||||
componentManager.activateComponent(component);
|
||||
componentManager.contextItemDidChangeInArea("editor-stack");
|
||||
this.associateComponentWithCurrentNote(component);
|
||||
@@ -517,8 +516,7 @@ angular.module('app')
|
||||
this.disassociateComponentWithCurrentNote = function(component) {
|
||||
component.associatedItemIds = component.associatedItemIds.filter((id) => {return id !== this.note.uuid});
|
||||
|
||||
// Only disassociative components should modify the disassociatedItemIds
|
||||
if(!component.isAssociative() && !component.disassociatedItemIds.includes(this.note.uuid)) {
|
||||
if(!component.disassociatedItemIds.includes(this.note.uuid)) {
|
||||
component.disassociatedItemIds.push(this.note.uuid);
|
||||
}
|
||||
|
||||
@@ -528,7 +526,7 @@ angular.module('app')
|
||||
this.associateComponentWithCurrentNote = function(component) {
|
||||
component.disassociatedItemIds = component.disassociatedItemIds.filter((id) => {return id !== this.note.uuid});
|
||||
|
||||
if(component.isAssociative() && !component.associatedItemIds.includes(this.note.uuid)) {
|
||||
if(!component.associatedItemIds.includes(this.note.uuid)) {
|
||||
component.associatedItemIds.push(this.note.uuid);
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,8 @@ class ComponentView {
|
||||
this.restrict = "E";
|
||||
this.templateUrl = "directives/component-view.html";
|
||||
this.scope = {
|
||||
component: "="
|
||||
component: "=",
|
||||
manualDealloc: "="
|
||||
};
|
||||
|
||||
this.componentManager = componentManager;
|
||||
@@ -79,7 +80,7 @@ class ComponentView {
|
||||
|
||||
$scope.$on("$destroy", function() {
|
||||
componentManager.deregisterHandler($scope.identifier);
|
||||
if($scope.component) {
|
||||
if($scope.component && !$scope.manualDealloc) {
|
||||
componentManager.deactivateComponent($scope.component);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -113,11 +113,11 @@ class Component extends Item {
|
||||
this.associatedItemIds.push(item.uuid);
|
||||
}
|
||||
|
||||
isActiveForItem(item) {
|
||||
if(this.isAssociative()) {
|
||||
return this.associatedItemIds.indexOf(item.uuid) !== -1;
|
||||
} else {
|
||||
return this.disassociatedItemIds.indexOf(item.uuid) === -1;
|
||||
}
|
||||
isExplicitlyEnabledForItem(item) {
|
||||
return this.associatedItemIds.indexOf(item.uuid) !== -1;
|
||||
}
|
||||
|
||||
isExplicitlyDisabledForItem(item) {
|
||||
return this.disassociatedItemIds.indexOf(item.uuid) !== -1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -593,6 +593,13 @@ class ComponentManager {
|
||||
}
|
||||
|
||||
sendMessageToComponent(component, message) {
|
||||
if(component.hidden && message.action !== "component-registered") {
|
||||
if(this.loggingEnabled) {
|
||||
console.log("Component disabled for current item, not sending any messages.", component.name);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if(this.loggingEnabled) {
|
||||
console.log("Web|sendMessageToComponent", component, message);
|
||||
}
|
||||
|
||||
@@ -117,6 +117,8 @@ class ModelManager {
|
||||
mapResponseItemsToLocalModelsOmittingFields(items, omitFields, source) {
|
||||
var models = [], processedObjects = [], modelsToNotifyObserversOf = [];
|
||||
|
||||
// console.log("mapResponseItemsToLocalModelsOmittingFields");
|
||||
|
||||
// first loop should add and process items
|
||||
for (var json_obj of items) {
|
||||
if((!json_obj.content_type || !json_obj.content) && !json_obj.deleted && !json_obj.errorDecrypting) {
|
||||
|
||||
@@ -109,6 +109,8 @@ class SingletonManager {
|
||||
this.modelManager.setItemToBeDeleted(d);
|
||||
}
|
||||
|
||||
console.log("Syncing from SM");
|
||||
|
||||
this.$rootScope.sync();
|
||||
|
||||
// Send remaining item to callback
|
||||
|
||||
@@ -191,6 +191,8 @@ class SyncManager {
|
||||
|
||||
sync(callback, options = {}) {
|
||||
|
||||
console.log("Sync");
|
||||
|
||||
var allDirtyItems = this.modelManager.getDirtyItems();
|
||||
|
||||
if(this.syncStatus.syncOpInProgress) {
|
||||
@@ -380,14 +382,13 @@ class SyncManager {
|
||||
console.log("Handle unsaved", unsaved);
|
||||
|
||||
var i = 0;
|
||||
var handleNext = function() {
|
||||
var handleNext = () => {
|
||||
if(i >= unsaved.length) {
|
||||
// Handled all items
|
||||
this.sync(null, {additionalFields: ["created_at", "updated_at"]});
|
||||
return;
|
||||
}
|
||||
|
||||
var handled = false;
|
||||
var mapping = unsaved[i];
|
||||
var itemResponse = mapping.item;
|
||||
EncryptionHelper.decryptMultipleItems([itemResponse], this.authManager.keys());
|
||||
@@ -403,8 +404,10 @@ class SyncManager {
|
||||
if(error.tag === "uuid_conflict") {
|
||||
// UUID conflicts can occur if a user attempts to
|
||||
// import an old data archive with uuids from the old account into a new account
|
||||
handled = true;
|
||||
this.modelManager.alternateUUIDForItem(item, handleNext, true);
|
||||
this.modelManager.alternateUUIDForItem(item, () => {
|
||||
i++;
|
||||
handleNext();
|
||||
}, true);
|
||||
}
|
||||
|
||||
else if(error.tag === "sync_conflict") {
|
||||
@@ -419,15 +422,11 @@ class SyncManager {
|
||||
dup.conflict_of = item.uuid;
|
||||
dup.setDirty(true);
|
||||
}
|
||||
}
|
||||
|
||||
++i;
|
||||
|
||||
if(!handled) {
|
||||
i++;
|
||||
handleNext();
|
||||
}
|
||||
|
||||
}.bind(this);
|
||||
}
|
||||
|
||||
handleNext();
|
||||
}
|
||||
|
||||
@@ -78,6 +78,7 @@
|
||||
.component-view {
|
||||
flex-grow: 1;
|
||||
display: flex;
|
||||
overflow: auto;
|
||||
iframe {
|
||||
flex: 1;
|
||||
width: 100%;
|
||||
|
||||
@@ -1,35 +1,36 @@
|
||||
.sn-component{"ng-if" => "!componentValid"}
|
||||
.panel.static
|
||||
.content
|
||||
%h2.title Unable to load Standard Notes Extended
|
||||
%p Your Extended subscription expired on {{component.dateToLocalizedString(component.valid_until)}}.
|
||||
%p
|
||||
Please visit
|
||||
%a{"href" => "https://dashboard.standardnotes.org", "target" => "_blank"} dashboard.standardnotes.org
|
||||
to renew your subscription, then open the "Extensions" menu via the bottom menu of the app to refresh your account data.
|
||||
Afterwards, press the button below to attempt to reload this component.
|
||||
.panel-row
|
||||
.button.info{"ng-if" => "!reloading", "ng-click" => "reloadStatus()"}
|
||||
.label Reload
|
||||
.spinner.info.small{"ng-if" => "reloading"}
|
||||
.panel-section
|
||||
%h2.title Unable to load Standard Notes Extended
|
||||
%p Your Extended subscription expired on {{component.dateToLocalizedString(component.valid_until)}}.
|
||||
%p
|
||||
Please visit
|
||||
%a{"href" => "https://dashboard.standardnotes.org", "target" => "_blank"} dashboard.standardnotes.org
|
||||
to renew your subscription, then open the "Extensions" menu via the bottom menu of the app to refresh your account data.
|
||||
Afterwards, press the button below to attempt to reload this component.
|
||||
.panel-row
|
||||
.button.info{"ng-if" => "!reloading", "ng-click" => "reloadStatus()"}
|
||||
.label Reload
|
||||
.spinner.info.small{"ng-if" => "reloading"}
|
||||
|
||||
.panel-row
|
||||
.panel-row
|
||||
.panel-column
|
||||
%p <strong>Otherwise</strong>, please follow the steps below to disable any external editors, so you can edit your note using the plain text editor instead.
|
||||
.panel-row
|
||||
.panel-row
|
||||
.panel-column
|
||||
%p <strong>Otherwise</strong>, please follow the steps below to disable any external editors, so you can edit your note using the plain text editor instead.
|
||||
|
||||
%p
|
||||
%ol
|
||||
%li Click the "Editor" menu item above (under the note title).
|
||||
%li Select "Plain Editor".
|
||||
%li Repeat this for every note you'd like to access. You can also delete the editor completely to disable it for all notes. To do so, click "Extensions" in the lower left corner of the app, then, for every editor, click "Uninstall".
|
||||
%p
|
||||
%ol
|
||||
%li Click the "Editor" menu item above (under the note title).
|
||||
%li Select "Plain Editor".
|
||||
%li Repeat this for every note you'd like to access. You can also delete the editor completely to disable it for all notes. To do so, click "Extensions" in the lower left corner of the app, then, for every editor, click "Uninstall".
|
||||
|
||||
%p
|
||||
Need help? Please email us at
|
||||
%a{"href" => "mailto:hello@standardnotes.org", "target" => "_blank"} hello@standardnotes.org
|
||||
or check out the
|
||||
%a{"href" => "https://standardnotes.org/help", "target" => "_blank"} Help
|
||||
page.
|
||||
%p
|
||||
Need help? Please email us at
|
||||
%a{"href" => "mailto:hello@standardnotes.org", "target" => "_blank"} hello@standardnotes.org
|
||||
or check out the
|
||||
%a{"href" => "https://standardnotes.org/help", "target" => "_blank"} Help
|
||||
page.
|
||||
|
||||
%iframe{"ng-if" => "component && componentValid",
|
||||
"ng-attr-id" => "component-{{component.uuid}}",
|
||||
|
||||
@@ -51,4 +51,4 @@
|
||||
%p.medium-padding{"style" => "padding-top: 0 !important;"} There was an error decrypting this item. Ensure you are running the latest version of this app, then sign out and sign back in to try again.
|
||||
|
||||
#editor-pane-component-stack
|
||||
%component-view.component-view.component-stack-item{"ng-repeat" => "component in ctrl.componentStack", "ng-if" => "component.active", "component" => "component"}
|
||||
%component-view.component-view.component-stack-item{"ng-repeat" => "component in ctrl.componentStack", "ng-if" => "component.active", "ng-show" => "!component.hidden", "manual-dealloc" => "true", "component" => "component"}
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
.sn-component
|
||||
#footer-bar.app-bar.no-edges
|
||||
.left
|
||||
.item{"click-outside" => "ctrl.showAccountMenu = false;", "is-open" => "ctrl.showAccountMenu"}
|
||||
.column{"ng-click" => "ctrl.accountMenuPressed()"}
|
||||
.item{"ng-click" => "ctrl.accountMenuPressed()", "click-outside" => "ctrl.showAccountMenu = false;", "is-open" => "ctrl.showAccountMenu"}
|
||||
.column
|
||||
.circle.small{"ng-class" => "ctrl.error ? 'danger' : (ctrl.getUser() ? 'info' : 'default')"}
|
||||
.column{"ng-click" => "ctrl.accountMenuPressed()"}
|
||||
.column
|
||||
.label.title{"ng-class" => "{red: ctrl.error}"} Account
|
||||
%account-menu{"ng-if" => "ctrl.showAccountMenu", "on-successful-auth" => "ctrl.onAuthSuccess", "close-function" => "ctrl.closeAccountMenu"}
|
||||
%account-menu{"ng-click" => "$event.stopPropagation()", "ng-if" => "ctrl.showAccountMenu", "on-successful-auth" => "ctrl.onAuthSuccess", "close-function" => "ctrl.closeAccountMenu"}
|
||||
|
||||
.item{"click-outside" => "ctrl.showExtensionsMenu = false;", "is-open" => "ctrl.showExtensionsMenu"}
|
||||
.column{"ng-click" => "ctrl.toggleExtensions()"}
|
||||
|
||||
Reference in New Issue
Block a user