Fixes #167, Item note cache is not set on new note creation
This commit is contained in:
parent
8dd972dea1
commit
1ce4de835b
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue
Block a user