From 9e0177f90ce7c9b13c3e7d5e60a6fb135263bd14 Mon Sep 17 00:00:00 2001 From: Dan Helfman Date: Tue, 6 May 2008 05:47:31 +0000 Subject: [PATCH] - bug: if you save a note that fails to be saved, e.g. due to being longer than 25k characters in size, then the note still shows up in recent updates. fixed by making it so that when an error is received by invoker, the error message is displayed but the callback is not invoked - bug: if you get an error when saving a note, the note should not disappear. it should still be present so you can try to save it again - make invoker not call a callback if there's an error - in Wiki.hide_editor(), only close an editor after save_editor() has invoked a provided callback function - make sure this doesn't break the note conflict notification error (saved editor should still shutdown) - test this in IE --- static/js/Invoker.js | 10 +++++----- static/js/Wiki.js | 16 +++++++++------- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/static/js/Invoker.js b/static/js/Invoker.js index c40a07b..c8f1ca6 100644 --- a/static/js/Invoker.js +++ b/static/js/Invoker.js @@ -70,18 +70,18 @@ Invoker.prototype.handle_response = function ( request, callback ) { var result = evalJSONRequest( request ); - if ( result.error ) + if ( result.error ) { signal( this, "error_message", result.error ); + return; + } if ( result.message ) signal( this, "message", result.message ); if ( callback ) callback( result ); - - if ( result.redirect ) + else if ( result.redirect ) window.location = result.redirect; - - if ( result.reload ) + else if ( result.reload ) window.location.reload(); } diff --git a/static/js/Wiki.js b/static/js/Wiki.js index f177c6f..2569372 100644 --- a/static/js/Wiki.js +++ b/static/js/Wiki.js @@ -1084,15 +1084,17 @@ Wiki.prototype.hide_editor = function ( event, editor ) { signal( this, "note_removed", editor.id ); editor.shutdown(); this.decrement_total_notes_count(); + this.display_empty_message(); } else { // before hiding an editor, save it - if ( this.notebook.read_write && editor.read_write ) - this.save_editor( editor ); - - editor.shutdown(); + if ( this.notebook.read_write && editor.read_write ) { + var self = this; + this.save_editor( editor, false, function () { + editor.shutdown(); + self.display_empty_message(); + } ); + } } - - this.display_empty_message(); } event.stop(); @@ -3090,6 +3092,6 @@ Recent_notes.prototype.update_link = function ( editor ) { // the link is already in the recent notes list, so just move it to the top of the list removeElement( item ); - replaceChildNodes( link, editor.title ); + replaceChildNodes( link, editor.title || "untitled note" ); insertSiblingNodesAfter( "recent_notes_top", item ); }