Improved dummy note handling, sfjs 0.3.61
This commit is contained in:
@@ -14,7 +14,7 @@ angular.module('app')
|
||||
bindToController: true,
|
||||
|
||||
link:function(scope, elem, attrs, ctrl) {
|
||||
scope.$watch('ctrl.note', function(note, oldNote){
|
||||
scope.$watch('ctrl.note', (note, oldNote) => {
|
||||
if(note) {
|
||||
ctrl.noteDidChange(note, oldNote);
|
||||
}
|
||||
@@ -43,9 +43,7 @@ angular.module('app')
|
||||
}
|
||||
|
||||
else if(eventName == "sync:completed") {
|
||||
|
||||
this.syncTakingTooLong = false;
|
||||
|
||||
if(this.note.dirty) {
|
||||
// if we're still dirty, don't change status, a sync is likely upcoming.
|
||||
} else {
|
||||
@@ -283,8 +281,6 @@ angular.module('app')
|
||||
return;
|
||||
}
|
||||
|
||||
modelManager.setItemDirty(note, true, updateClientModified);
|
||||
|
||||
this.showSavingStatus();
|
||||
|
||||
if(!dontUpdatePreviews) {
|
||||
@@ -292,11 +288,12 @@ angular.module('app')
|
||||
var text = note.text || "";
|
||||
var truncate = text.length > limit;
|
||||
note.content.preview_plain = text.substring(0, limit) + (truncate ? "..." : "");
|
||||
|
||||
// Clear dynamic previews if using plain editor
|
||||
note.content.preview_html = null;
|
||||
}
|
||||
|
||||
modelManager.setItemDirty(note, true, updateClientModified);
|
||||
|
||||
if(this.saveTimeout) {
|
||||
$timeout.cancel(this.saveTimeout);
|
||||
}
|
||||
|
||||
@@ -238,6 +238,7 @@ angular.module('app')
|
||||
|
||||
$scope.notesAddNew = function(note) {
|
||||
modelManager.addItem(note);
|
||||
modelManager.setItemDirty(note);
|
||||
|
||||
if(!$scope.selectedTag.isSmartTag()) {
|
||||
$scope.selectedTag.addItemAsRelationship(note);
|
||||
|
||||
@@ -40,14 +40,28 @@ angular.module('app')
|
||||
modelManager.removeItemLocally(this.selectedNote);
|
||||
_.pull(this.notes, this.selectedNote);
|
||||
this.selectedNote = null;
|
||||
this.selectNote(null);
|
||||
|
||||
// We now want to see if the user will download any items from the server.
|
||||
// If the next sync completes and our notes are still 0, we need to create a dummy.
|
||||
this.createDummyOnSynCompletionIfNoNotes = true;
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
syncManager.addEventHandler((syncEvent, data) => {
|
||||
if(syncEvent == "local-data-loaded") {
|
||||
this.localDataLoaded = true;
|
||||
this.needsHandleDataLoad = true;
|
||||
if(this.notes.length == 0) {
|
||||
this.createNewNote();
|
||||
}
|
||||
} else if(syncEvent == "sync:completed") {
|
||||
// Pad with a timeout just to be extra patient
|
||||
$timeout(() => {
|
||||
if(this.createDummyOnSynCompletionIfNoNotes && this.notes.length == 0) {
|
||||
this.createDummyOnSynCompletionIfNoNotes = false;
|
||||
this.createNewNote();
|
||||
}
|
||||
}, 100)
|
||||
}
|
||||
});
|
||||
|
||||
@@ -55,13 +69,6 @@ angular.module('app')
|
||||
// reload our notes
|
||||
this.reloadNotes();
|
||||
|
||||
if(this.needsHandleDataLoad) {
|
||||
this.needsHandleDataLoad = false;
|
||||
if(this.tag && this.notes.length == 0) {
|
||||
this.createNewNote();
|
||||
}
|
||||
}
|
||||
|
||||
// Note has changed values, reset its flags
|
||||
let notes = allItems.filter((item) => item.content_type == "Note");
|
||||
for(let note of notes) {
|
||||
@@ -305,8 +312,8 @@ angular.module('app')
|
||||
|
||||
this.showMenu = false;
|
||||
|
||||
if(this.selectedNote && this.selectedNote.dummy) {
|
||||
if(oldTag) {
|
||||
if(this.selectedNote) {
|
||||
if(this.selectedNote.dummy && oldTag) {
|
||||
_.remove(oldTag.notes, this.selectedNote);
|
||||
}
|
||||
}
|
||||
@@ -320,8 +327,14 @@ angular.module('app')
|
||||
if(this.notes.length > 0) {
|
||||
this.notes.forEach((note) => { note.visible = true; })
|
||||
this.selectFirstNote();
|
||||
} else if(this.localDataLoaded) {
|
||||
this.createNewNote();
|
||||
} else if(syncManager.initialDataLoaded()) {
|
||||
if(!tag.isSmartTag()) {
|
||||
this.createNewNote();
|
||||
} else {
|
||||
if(this.selectedNote && !this.notes.includes(this.selectedNote)) {
|
||||
this.selectNote(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -360,6 +373,7 @@ angular.module('app')
|
||||
|
||||
this.selectNote = async function(note, viaClick = false) {
|
||||
if(!note) {
|
||||
this.selectionMade()(null);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -74,7 +74,7 @@ class ActionsManager {
|
||||
|
||||
if(!item.errorDecrypting) {
|
||||
if(merge) {
|
||||
var items = this.modelManager.mapResponseItemsToLocalModels([item], SFModelManager.MappingSourceRemoteActionRetrieved);
|
||||
var items = await this.modelManager.mapResponseItemsToLocalModels([item], SFModelManager.MappingSourceRemoteActionRetrieved);
|
||||
for(var mappedItem of items) {
|
||||
this.modelManager.setItemDirty(mappedItem, true);
|
||||
}
|
||||
|
||||
@@ -55,7 +55,7 @@ class NativeExtManager {
|
||||
}, (valueCallback) => {
|
||||
// Safe to create. Create and return object.
|
||||
let url = window._extensions_manager_location;
|
||||
console.log("Installing Extensions Manager from URL", url);
|
||||
// console.log("Installing Extensions Manager from URL", url);
|
||||
if(!url) {
|
||||
console.error("window._extensions_manager_location must be set.");
|
||||
return;
|
||||
@@ -131,7 +131,7 @@ class NativeExtManager {
|
||||
}, (valueCallback) => {
|
||||
// Safe to create. Create and return object.
|
||||
let url = window._batch_manager_location;
|
||||
console.log("Installing Batch Manager from URL", url);
|
||||
// console.log("Installing Batch Manager from URL", url);
|
||||
if(!url) {
|
||||
console.error("window._batch_manager_location must be set.");
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user