Fixes alternateUUID callback, component stack association
This commit is contained in:
@@ -92,7 +92,7 @@ angular.module('app')
|
|||||||
this.editorForNote = function(note) {
|
this.editorForNote = function(note) {
|
||||||
let editors = componentManager.componentsForArea("editor-editor");
|
let editors = componentManager.componentsForArea("editor-editor");
|
||||||
for(var editor of editors) {
|
for(var editor of editors) {
|
||||||
if(editor.isActiveForItem(note)) {
|
if(editor.isExplicitlyEnabledForItem(note)) {
|
||||||
return editor;
|
return editor;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -427,7 +427,7 @@ angular.module('app')
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Editor
|
// 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;
|
this.selectedEditor = component;
|
||||||
} else {
|
} else {
|
||||||
this.selectedEditor = null;
|
this.selectedEditor = null;
|
||||||
@@ -490,24 +490,23 @@ angular.module('app')
|
|||||||
|
|
||||||
var stack = componentManager.componentsForArea("editor-stack");
|
var stack = componentManager.componentsForArea("editor-stack");
|
||||||
for(var component of stack) {
|
for(var component of stack) {
|
||||||
var activeForItem = component.isActiveForItem(this.note);
|
|
||||||
if(activeForItem) {
|
|
||||||
if(!component.active) {
|
|
||||||
componentManager.activateComponent(component);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if(component.active) {
|
if(component.active) {
|
||||||
componentManager.deactivateComponent(component);
|
var disabledForItem = component.isExplicitlyDisabledForItem(this.note);
|
||||||
|
if(disabledForItem) {
|
||||||
|
component.hidden = true;
|
||||||
|
} else {
|
||||||
|
component.hidden = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.toggleStackComponentForCurrentItem = function(component) {
|
this.toggleStackComponentForCurrentItem = function(component) {
|
||||||
if(component.isActiveForItem(this.note)) {
|
if(component.active) {
|
||||||
componentManager.deactivateComponent(component);
|
component.hidden = true;
|
||||||
this.disassociateComponentWithCurrentNote(component);
|
this.disassociateComponentWithCurrentNote(component);
|
||||||
} else {
|
} else {
|
||||||
|
// Inactive
|
||||||
componentManager.activateComponent(component);
|
componentManager.activateComponent(component);
|
||||||
componentManager.contextItemDidChangeInArea("editor-stack");
|
componentManager.contextItemDidChangeInArea("editor-stack");
|
||||||
this.associateComponentWithCurrentNote(component);
|
this.associateComponentWithCurrentNote(component);
|
||||||
@@ -517,8 +516,7 @@ angular.module('app')
|
|||||||
this.disassociateComponentWithCurrentNote = function(component) {
|
this.disassociateComponentWithCurrentNote = function(component) {
|
||||||
component.associatedItemIds = component.associatedItemIds.filter((id) => {return id !== this.note.uuid});
|
component.associatedItemIds = component.associatedItemIds.filter((id) => {return id !== this.note.uuid});
|
||||||
|
|
||||||
// Only disassociative components should modify the disassociatedItemIds
|
if(!component.disassociatedItemIds.includes(this.note.uuid)) {
|
||||||
if(!component.isAssociative() && !component.disassociatedItemIds.includes(this.note.uuid)) {
|
|
||||||
component.disassociatedItemIds.push(this.note.uuid);
|
component.disassociatedItemIds.push(this.note.uuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -528,7 +526,7 @@ angular.module('app')
|
|||||||
this.associateComponentWithCurrentNote = function(component) {
|
this.associateComponentWithCurrentNote = function(component) {
|
||||||
component.disassociatedItemIds = component.disassociatedItemIds.filter((id) => {return id !== this.note.uuid});
|
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);
|
component.associatedItemIds.push(this.note.uuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,8 @@ class ComponentView {
|
|||||||
this.restrict = "E";
|
this.restrict = "E";
|
||||||
this.templateUrl = "directives/component-view.html";
|
this.templateUrl = "directives/component-view.html";
|
||||||
this.scope = {
|
this.scope = {
|
||||||
component: "="
|
component: "=",
|
||||||
|
manualDealloc: "="
|
||||||
};
|
};
|
||||||
|
|
||||||
this.componentManager = componentManager;
|
this.componentManager = componentManager;
|
||||||
@@ -79,7 +80,7 @@ class ComponentView {
|
|||||||
|
|
||||||
$scope.$on("$destroy", function() {
|
$scope.$on("$destroy", function() {
|
||||||
componentManager.deregisterHandler($scope.identifier);
|
componentManager.deregisterHandler($scope.identifier);
|
||||||
if($scope.component) {
|
if($scope.component && !$scope.manualDealloc) {
|
||||||
componentManager.deactivateComponent($scope.component);
|
componentManager.deactivateComponent($scope.component);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -113,11 +113,11 @@ class Component extends Item {
|
|||||||
this.associatedItemIds.push(item.uuid);
|
this.associatedItemIds.push(item.uuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
isActiveForItem(item) {
|
isExplicitlyEnabledForItem(item) {
|
||||||
if(this.isAssociative()) {
|
|
||||||
return this.associatedItemIds.indexOf(item.uuid) !== -1;
|
return this.associatedItemIds.indexOf(item.uuid) !== -1;
|
||||||
} else {
|
|
||||||
return this.disassociatedItemIds.indexOf(item.uuid) === -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
isExplicitlyDisabledForItem(item) {
|
||||||
|
return this.disassociatedItemIds.indexOf(item.uuid) !== -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -593,6 +593,13 @@ class ComponentManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
sendMessageToComponent(component, message) {
|
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) {
|
if(this.loggingEnabled) {
|
||||||
console.log("Web|sendMessageToComponent", component, message);
|
console.log("Web|sendMessageToComponent", component, message);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -117,6 +117,8 @@ class ModelManager {
|
|||||||
mapResponseItemsToLocalModelsOmittingFields(items, omitFields, source) {
|
mapResponseItemsToLocalModelsOmittingFields(items, omitFields, source) {
|
||||||
var models = [], processedObjects = [], modelsToNotifyObserversOf = [];
|
var models = [], processedObjects = [], modelsToNotifyObserversOf = [];
|
||||||
|
|
||||||
|
// console.log("mapResponseItemsToLocalModelsOmittingFields");
|
||||||
|
|
||||||
// first loop should add and process items
|
// first loop should add and process items
|
||||||
for (var json_obj of items) {
|
for (var json_obj of items) {
|
||||||
if((!json_obj.content_type || !json_obj.content) && !json_obj.deleted && !json_obj.errorDecrypting) {
|
if((!json_obj.content_type || !json_obj.content) && !json_obj.deleted && !json_obj.errorDecrypting) {
|
||||||
|
|||||||
@@ -109,6 +109,8 @@ class SingletonManager {
|
|||||||
this.modelManager.setItemToBeDeleted(d);
|
this.modelManager.setItemToBeDeleted(d);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
console.log("Syncing from SM");
|
||||||
|
|
||||||
this.$rootScope.sync();
|
this.$rootScope.sync();
|
||||||
|
|
||||||
// Send remaining item to callback
|
// Send remaining item to callback
|
||||||
|
|||||||
@@ -191,6 +191,8 @@ class SyncManager {
|
|||||||
|
|
||||||
sync(callback, options = {}) {
|
sync(callback, options = {}) {
|
||||||
|
|
||||||
|
console.log("Sync");
|
||||||
|
|
||||||
var allDirtyItems = this.modelManager.getDirtyItems();
|
var allDirtyItems = this.modelManager.getDirtyItems();
|
||||||
|
|
||||||
if(this.syncStatus.syncOpInProgress) {
|
if(this.syncStatus.syncOpInProgress) {
|
||||||
@@ -380,14 +382,13 @@ class SyncManager {
|
|||||||
console.log("Handle unsaved", unsaved);
|
console.log("Handle unsaved", unsaved);
|
||||||
|
|
||||||
var i = 0;
|
var i = 0;
|
||||||
var handleNext = function() {
|
var handleNext = () => {
|
||||||
if(i >= unsaved.length) {
|
if(i >= unsaved.length) {
|
||||||
// Handled all items
|
// Handled all items
|
||||||
this.sync(null, {additionalFields: ["created_at", "updated_at"]});
|
this.sync(null, {additionalFields: ["created_at", "updated_at"]});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var handled = false;
|
|
||||||
var mapping = unsaved[i];
|
var mapping = unsaved[i];
|
||||||
var itemResponse = mapping.item;
|
var itemResponse = mapping.item;
|
||||||
EncryptionHelper.decryptMultipleItems([itemResponse], this.authManager.keys());
|
EncryptionHelper.decryptMultipleItems([itemResponse], this.authManager.keys());
|
||||||
@@ -403,8 +404,10 @@ class SyncManager {
|
|||||||
if(error.tag === "uuid_conflict") {
|
if(error.tag === "uuid_conflict") {
|
||||||
// UUID conflicts can occur if a user attempts to
|
// UUID conflicts can occur if a user attempts to
|
||||||
// import an old data archive with uuids from the old account into a new account
|
// import an old data archive with uuids from the old account into a new account
|
||||||
handled = true;
|
this.modelManager.alternateUUIDForItem(item, () => {
|
||||||
this.modelManager.alternateUUIDForItem(item, handleNext, true);
|
i++;
|
||||||
|
handleNext();
|
||||||
|
}, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
else if(error.tag === "sync_conflict") {
|
else if(error.tag === "sync_conflict") {
|
||||||
@@ -419,15 +422,11 @@ class SyncManager {
|
|||||||
dup.conflict_of = item.uuid;
|
dup.conflict_of = item.uuid;
|
||||||
dup.setDirty(true);
|
dup.setDirty(true);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
++i;
|
i++;
|
||||||
|
|
||||||
if(!handled) {
|
|
||||||
handleNext();
|
handleNext();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}.bind(this);
|
|
||||||
|
|
||||||
handleNext();
|
handleNext();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -78,6 +78,7 @@
|
|||||||
.component-view {
|
.component-view {
|
||||||
flex-grow: 1;
|
flex-grow: 1;
|
||||||
display: flex;
|
display: flex;
|
||||||
|
overflow: auto;
|
||||||
iframe {
|
iframe {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
.sn-component{"ng-if" => "!componentValid"}
|
.sn-component{"ng-if" => "!componentValid"}
|
||||||
.panel.static
|
.panel.static
|
||||||
.content
|
.content
|
||||||
|
.panel-section
|
||||||
%h2.title Unable to load Standard Notes Extended
|
%h2.title Unable to load Standard Notes Extended
|
||||||
%p Your Extended subscription expired on {{component.dateToLocalizedString(component.valid_until)}}.
|
%p Your Extended subscription expired on {{component.dateToLocalizedString(component.valid_until)}}.
|
||||||
%p
|
%p
|
||||||
|
|||||||
@@ -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.
|
%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
|
#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
|
.sn-component
|
||||||
#footer-bar.app-bar.no-edges
|
#footer-bar.app-bar.no-edges
|
||||||
.left
|
.left
|
||||||
.item{"click-outside" => "ctrl.showAccountMenu = false;", "is-open" => "ctrl.showAccountMenu"}
|
.item{"ng-click" => "ctrl.accountMenuPressed()", "click-outside" => "ctrl.showAccountMenu = false;", "is-open" => "ctrl.showAccountMenu"}
|
||||||
.column{"ng-click" => "ctrl.accountMenuPressed()"}
|
.column
|
||||||
.circle.small{"ng-class" => "ctrl.error ? 'danger' : (ctrl.getUser() ? 'info' : 'default')"}
|
.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
|
.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"}
|
.item{"click-outside" => "ctrl.showExtensionsMenu = false;", "is-open" => "ctrl.showExtensionsMenu"}
|
||||||
.column{"ng-click" => "ctrl.toggleExtensions()"}
|
.column{"ng-click" => "ctrl.toggleExtensions()"}
|
||||||
|
|||||||
Reference in New Issue
Block a user