Fixes altnernate uuids on sign in to notify observers, fixes dummy note becoming undummy

This commit is contained in:
Mo Bitar
2018-01-12 16:38:26 -06:00
parent c7ce308a19
commit a679f82859
8 changed files with 27 additions and 25 deletions

View File

@@ -245,7 +245,6 @@ angular.module('app.frontend')
this.onNameBlur = function() {
this.editingName = false;
this.updateTagsFromTagsString()
}
this.toggleFullScreen = function() {

View File

@@ -115,8 +115,8 @@ angular.module('app.frontend')
this.rooms = [];
modelManager.addItemSyncObserver("room-bar", "SN|Component", (allItems, validItems, deletedItems, source) => {
this.rooms = _.uniq(this.rooms.concat(allItems.filter((candidate) => {return candidate.area == "rooms"})))
.filter((candidate) => {return !candidate.deleted});
var incomingRooms = allItems.filter((candidate) => {return candidate.area == "rooms"});
this.rooms = _.uniq(this.rooms.concat(incomingRooms)).filter((candidate) => {return !candidate.deleted});
});
componentManager.registerHandler({identifier: "roomBar", areas: ["rooms"], activationHandler: (component) => {
@@ -161,9 +161,7 @@ angular.module('app.frontend')
// Handle singleton ProLink instance
singletonManager.registerSingleton({content_type: "SN|Component", package_info: {identifier: "org.standardnotes.prolink"}}, (resolvedSingleton) => {
}, (valueCallback) => {
// Safe to create. Create and return object.
let url = window._prolink_package_url;
console.log("Installing ProLink from URL", url);

View File

@@ -62,9 +62,10 @@ class ModelManager {
}
if(removeOriginal) {
this.removeItemLocally(item, function(){
block();
});
// Set to deleted, then run through mapping function so that observers can be notified
item.deleted = true;
this.mapResponseItemsToLocalModels([item], ModelManager.MappingSourceLocalSaved);
block();
} else {
block();
}
@@ -81,13 +82,13 @@ class ModelManager {
}
allItemsMatchingTypes(contentTypes) {
return this.items.filter(function(item){
return this.allItems.filter(function(item){
return (_.includes(contentTypes, item.content_type) || _.includes(contentTypes, "*")) && !item.dummy;
})
}
itemsForContentType(contentType) {
return this.items.filter(function(item){
return this.allItems.filter(function(item){
return item.content_type == contentType;
});
}

View File

@@ -24,10 +24,10 @@ class SingletonManager {
})
// Testing code to make sure only 1 exists
setTimeout(function () {
var userPrefs = modelManager.itemsForContentType("SN|UserPreferences");
console.assert(userPrefs.length == 1);
}, 1000);
// setTimeout(function () {
// var userPrefs = modelManager.itemsForContentType("SN|UserPreferences");
// console.assert(userPrefs.length == 1);
// }, 1000);
}
registerSingleton(predicate, resolveCallback, createBlock) {

View File

@@ -84,6 +84,8 @@ class SyncManager {
// use a copy, as alternating uuid will affect array
var originalItems = this.modelManager.allItems.slice();
console.log("markAllItemsDirtyAndSaveOffline", originalItems);
var block = () => {
var allItems = this.modelManager.allItems;
for(var item of allItems) {
@@ -97,7 +99,7 @@ class SyncManager {
let alternateNextItem = () => {
if(index >= originalItems.length) {
// We don't use originalItems as altnerating UUID will have deleted them.
// We don't use originalItems as alternating UUID will have deleted them.
block();
return;
}