From 1ce4de835b6ae57d594a51734662b394e868cea5 Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Sat, 5 Aug 2006 07:42:32 +0000 Subject: [PATCH] Fixes #167, Item note cache is not set on new note creation --- .../content/scholar/xpcom/data_access.js | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/chrome/chromeFiles/content/scholar/xpcom/data_access.js b/chrome/chromeFiles/content/scholar/xpcom/data_access.js index 77dc0c7ac..4eb6da497 100644 --- a/chrome/chromeFiles/content/scholar/xpcom/data_access.js +++ b/chrome/chromeFiles/content/scholar/xpcom/data_access.js @@ -838,10 +838,7 @@ Scholar.Item.prototype.updateNote = function(text){ if (updated){ this.updateDateModified(); Scholar.DB.commitTransaction(); - - // Update cached values - this._noteData = text ? text : ''; - this.setField('title', this._noteToTitle(), true); + this.updateNoteCache(text); Scholar.Notifier.trigger('modify', 'item', this.getID()); } @@ -851,6 +848,13 @@ Scholar.Item.prototype.updateNote = function(text){ } +Scholar.Item.prototype.updateNoteCache = function(text){ + // Update cached values + this._noteData = text ? text : ''; + this.setField('title', this._noteToTitle(), true); +} + + Scholar.Item.prototype.setSource = function(sourceItemID){ if (this.isNote()){ var type = 'note'; @@ -992,7 +996,6 @@ Scholar.Item.prototype.getSource = function(){ **/ Scholar.Item.prototype.getNotes = function(){ if (this.isNote()){ - Scholar.debug('here'); throw ("getNotes() cannot be called on items of type 'note'"); } @@ -1867,6 +1870,10 @@ Scholar.Notes = new function(){ Scholar.DB.query(sql, bindParams); Scholar.DB.commitTransaction(); + // Switch to Scholar.Items version + var note = Scholar.Items.get(note.getID()); + note.updateNoteCache(text); + if (sourceItemID){ sourceItem.incrementNoteCount(); Scholar.Notifier.trigger('modify', 'item', sourceItemID);