Updates
This commit is contained in:
@@ -163,4 +163,7 @@ module.exports = function(grunt) {
|
|||||||
|
|
||||||
grunt.registerTask('default', ['haml', 'ngtemplates', 'sass', 'concat:app', 'babel', 'browserify',
|
grunt.registerTask('default', ['haml', 'ngtemplates', 'sass', 'concat:app', 'babel', 'browserify',
|
||||||
'concat:lib', 'concat:dist', 'ngAnnotate', 'concat:css', 'uglify']);
|
'concat:lib', 'concat:dist', 'ngAnnotate', 'concat:css', 'uglify']);
|
||||||
|
|
||||||
|
grunt.registerTask('vendor', ['concat:app', 'babel', 'browserify',
|
||||||
|
'concat:lib', 'concat:dist', 'ngAnnotate', 'concat:css', 'uglify']);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -36,10 +36,6 @@ angular.module('app')
|
|||||||
this.syncTakingTooLong = false;
|
this.syncTakingTooLong = false;
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
|
|
||||||
$rootScope.$on("tag-changed", function(){
|
|
||||||
this.loadTagsString();
|
|
||||||
}.bind(this));
|
|
||||||
|
|
||||||
// Right now this only handles offline saving status changes.
|
// Right now this only handles offline saving status changes.
|
||||||
this.syncStatusObserver = syncManager.registerSyncStatusObserver((status) => {
|
this.syncStatusObserver = syncManager.registerSyncStatusObserver((status) => {
|
||||||
if(status.localError) {
|
if(status.localError) {
|
||||||
@@ -80,6 +76,18 @@ angular.module('app')
|
|||||||
this.loadTagsString();
|
this.loadTagsString();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
modelManager.addItemSyncObserver("component-manager", "Tag", (allItems, validItems, deletedItems, source) => {
|
||||||
|
if(!this.note) { return; }
|
||||||
|
|
||||||
|
for(var tag of allItems) {
|
||||||
|
// If a tag is deleted then we'll have lost references to notes. Reload anyway.
|
||||||
|
if(this.note.savedTagsString == null || tag.deleted || tag.hasRelationshipWithItem(this.note)) {
|
||||||
|
this.loadTagsString();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
this.noteDidChange = function(note, oldNote) {
|
this.noteDidChange = function(note, oldNote) {
|
||||||
this.setNote(note, oldNote);
|
this.setNote(note, oldNote);
|
||||||
this.reloadComponentContext();
|
this.reloadComponentContext();
|
||||||
@@ -554,7 +562,7 @@ angular.module('app')
|
|||||||
|
|
||||||
// Currently extensions are not notified of association until a full server sync completes.
|
// Currently extensions are not notified of association until a full server sync completes.
|
||||||
// We need a better system for this, but for now, we'll manually notify observers
|
// We need a better system for this, but for now, we'll manually notify observers
|
||||||
modelManager.notifySyncObserversOfModels([this.note], SFModelManager.MappingSourceLocalSaved);
|
modelManager.notifySyncObserversOfModels([tag], SFModelManager.MappingSourceLocalSaved);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -564,7 +572,7 @@ angular.module('app')
|
|||||||
|
|
||||||
// Currently extensions are not notified of association until a full server sync completes.
|
// Currently extensions are not notified of association until a full server sync completes.
|
||||||
// We need a better system for this, but for now, we'll manually notify observers
|
// We need a better system for this, but for now, we'll manually notify observers
|
||||||
modelManager.notifySyncObserversOfModels([this.note], SFModelManager.MappingSourceLocalSaved);
|
modelManager.notifySyncObserversOfModels([tag], SFModelManager.MappingSourceLocalSaved);
|
||||||
}
|
}
|
||||||
|
|
||||||
else if(action === "save-items" || action === "save-success" || action == "save-error") {
|
else if(action === "save-items" || action === "save-success" || action == "save-error") {
|
||||||
|
|||||||
@@ -180,7 +180,6 @@ angular.module('app')
|
|||||||
}
|
}
|
||||||
tag.setDirty(true);
|
tag.setDirty(true);
|
||||||
syncManager.sync().then(callback);
|
syncManager.sync().then(callback);
|
||||||
$rootScope.$broadcast("tag-changed");
|
|
||||||
modelManager.resortTag(tag);
|
modelManager.resortTag(tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -47,6 +47,10 @@ class DBManager {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
request.onblocked = (event) => {
|
||||||
|
console.error("Request blocked error:", event.target.errorCode);
|
||||||
|
}
|
||||||
|
|
||||||
request.onupgradeneeded = (event) => {
|
request.onupgradeneeded = (event) => {
|
||||||
var db = event.target.result;
|
var db = event.target.result;
|
||||||
|
|
||||||
@@ -106,7 +110,11 @@ class DBManager {
|
|||||||
};
|
};
|
||||||
|
|
||||||
transaction.onerror = function(event) {
|
transaction.onerror = function(event) {
|
||||||
console.log("Transaction error:", event.target.errorCode);
|
console.error("Transaction error:", event.target.errorCode);
|
||||||
|
};
|
||||||
|
|
||||||
|
transaction.onblocked = function(event) {
|
||||||
|
console.error("Transaction blocked error:", event.target.errorCode);
|
||||||
};
|
};
|
||||||
|
|
||||||
transaction.onabort = function(event) {
|
transaction.onabort = function(event) {
|
||||||
@@ -127,12 +135,14 @@ class DBManager {
|
|||||||
function putNext() {
|
function putNext() {
|
||||||
if (i < items.length) {
|
if (i < items.length) {
|
||||||
var item = items[i];
|
var item = items[i];
|
||||||
itemObjectStore.put(item).onsuccess = putNext;
|
var request = itemObjectStore.put(item);
|
||||||
|
request.onerror = (event) => {
|
||||||
|
console.error("DB put error:", event.target.error);
|
||||||
|
}
|
||||||
|
request.onsuccess = putNext;
|
||||||
++i;
|
++i;
|
||||||
} else {
|
} else {
|
||||||
if(onsuccess){
|
onsuccess && onsuccess();
|
||||||
onsuccess();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, null)
|
}, null)
|
||||||
|
|||||||
@@ -157,6 +157,32 @@ describe("notes and tags", () => {
|
|||||||
expect(tag.notes.length).to.equal(0);
|
expect(tag.notes.length).to.equal(0);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it.only('resets cached note tags string when tag is renamed', () => {
|
||||||
|
let modelManager = Factory.createModelManager();
|
||||||
|
|
||||||
|
let pair = createRelatedNoteTagPair();
|
||||||
|
let noteParams = pair[0];
|
||||||
|
let tagParams = pair[1];
|
||||||
|
|
||||||
|
modelManager.mapResponseItemsToLocalModels([noteParams, tagParams]);
|
||||||
|
let note = modelManager.allItemsMatchingTypes(["Note"])[0];
|
||||||
|
let tag = modelManager.allItemsMatchingTypes(["Tag"])[0];
|
||||||
|
|
||||||
|
expect(note.tagsString()).to.equal(`#${tagParams.content.title}`);
|
||||||
|
|
||||||
|
var title = Math.random();
|
||||||
|
|
||||||
|
// Saving involves modifying local state first, then syncing with omitting content.
|
||||||
|
tag.title = title;
|
||||||
|
tagParams.content.title = title;
|
||||||
|
// simulate a save, which omits `content`
|
||||||
|
modelManager.mapResponseItemsToLocalModelsOmittingFields([tagParams], ['content']);
|
||||||
|
|
||||||
|
// should be null
|
||||||
|
expect(note.savedTagsString).to.not.be.ok;
|
||||||
|
expect(note.tagsString()).to.equal(`#${title}`);
|
||||||
|
});
|
||||||
|
|
||||||
it('handles removing relationship between note and tag', () => {
|
it('handles removing relationship between note and tag', () => {
|
||||||
let modelManager = Factory.createModelManager();
|
let modelManager = Factory.createModelManager();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user