From 31975e00427c77072dfdeb7baf9cef629748bada Mon Sep 17 00:00:00 2001 From: Jermolene Date: Fri, 21 Feb 2014 18:15:18 +0000 Subject: [PATCH] Update importing so we don't open every imported tiddler Instead we just display a report with links to each imported tiddler. Should make importing much faster. --- core/modules/widgets/navigator.js | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/core/modules/widgets/navigator.js b/core/modules/widgets/navigator.js index 56373bcbd..d83131cde 100755 --- a/core/modules/widgets/navigator.js +++ b/core/modules/widgets/navigator.js @@ -358,9 +358,6 @@ NavigatorWidget.prototype.handleNewTiddlerEvent = function(event) { // Import JSON tiddlers NavigatorWidget.prototype.handleImportTiddlersEvent = function(event) { var self = this; - // Get the story and history details - var storyList = this.getStoryList(); - var history = []; // Get the tiddlers var tiddlers = []; try { @@ -368,6 +365,7 @@ NavigatorWidget.prototype.handleImportTiddlersEvent = function(event) { } catch(e) { } // Process each tiddler + var importedTiddlers = []; $tw.utils.each(tiddlers,function(tiddlerFields) { var title = tiddlerFields.title; // Add it to the store @@ -377,14 +375,28 @@ NavigatorWidget.prototype.handleImportTiddlersEvent = function(event) { tiddlerFields )); if(imported) { - // Add it to the story - if(storyList.indexOf(title) === -1) { - storyList.unshift(title); - } - // And to history - history.push(title); + importedTiddlers.push(title); } }); + // Get the story and history details + var storyList = this.getStoryList(), + history = []; + // Create the import report tiddler + var tiddlerFields = { + title: this.wiki.generateNewTitle("$:/temp/Import Report"), + text: "# [[" + importedTiddlers.join("]]\n# [[") + "]]\n" + }; + this.wiki.addTiddler(new $tw.Tiddler( + self.wiki.getCreationFields(), + tiddlerFields, + self.wiki.getModificationFields() + )); + // Add it to the story + if(storyList.indexOf(tiddlerFields.title) === -1) { + storyList.unshift(tiddlerFields.title); + } + // And to history + history.push(tiddlerFields.title); // Save the updated story and history this.saveStoryList(storyList); this.addToHistory(history);