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 ); }