diff --git a/core/client.js b/core/client.js index c02944ea..1cfd6bdc 100644 --- a/core/client.js +++ b/core/client.js @@ -394,9 +394,13 @@ function Client(input, output) { self.detachCurrentMenuModule = function() { if(self.currentMenuModule) { + + var savedState = self.currentMenuModule.getSaveState(); + self.currentMenuModule.leave(); - self.lastMenuModuleInfo = self.currentMenuModuleInfo; + self.lastMenuModuleInfo = self.currentMenuModuleInfo; + self.lastMenuModuleInfo.savedState = savedState; self.currentMenuModule = null; } @@ -463,6 +467,10 @@ Client.prototype.gotoMenuModule = function(options, cb) { extraArgs : options.extraArgs, } + if(options.savedState) { + modInst.restoreSavedState(options.savedState); + } + modInst.enter(self); if(!callbackOnErrorOnly) { @@ -479,6 +487,7 @@ Client.prototype.fallbackMenuModule = function(cb) { var modOpts = { name : self.lastMenuModuleInfo.menuName, extraArgs : self.lastMenuModuleInfo.extraArgs, + savedState : self.lastMenuModuleInfo.savedState, }; self.gotoMenuModule(modOpts, cb); diff --git a/core/menu_module.js b/core/menu_module.js index e47658c0..70d3ab50 100644 --- a/core/menu_module.js +++ b/core/menu_module.js @@ -185,6 +185,7 @@ require('util').inherits(MenuModule, PluginModule); require('./mod_mixins.js').ViewControllerManagement.call(MenuModule.prototype); + MenuModule.prototype.enter = function(client) { this.client = client; assert(_.isObject(client)); @@ -198,6 +199,14 @@ MenuModule.prototype.enter = function(client) { this.initSequence(); }; +MenuModule.prototype.getSaveState = function() { + // nothing in base +}; + +MenuModule.prototype.restoreSavedState = function(savedState) { + // nothing in base +}; + MenuModule.prototype.leave = function() { this.detachViewControllers(); }; diff --git a/mods/msg_area_view_fse.js b/mods/msg_area_view_fse.js index 66deeae2..e209a279 100644 --- a/mods/msg_area_view_fse.js +++ b/mods/msg_area_view_fse.js @@ -55,6 +55,7 @@ function AreaViewFSEModule(options) { this.menuMethods.movementKeyPressed = function(formData, extraArgs) { var bodyView = self.viewControllers.body.getView(1); + // :TODO: Create methods for up/down vs using keyPressXXXXX switch(formData.key.name) { case 'down arrow' : bodyView.scrollDocumentUp(); break; case 'up arrow' : bodyView.scrollDocumentDown(); break; @@ -93,4 +94,22 @@ AreaViewFSEModule.prototype.finishedLoading = function() { if(this.messageList.length) { this.loadMessageByUuid(this.messageList[this.messageIndex].messageUuid); } +}; + +AreaViewFSEModule.prototype.getSaveState = function() { + AreaViewFSEModule.super_.prototype.getSaveState.call(this); + + return { + messageList : this.messageList, + messageIndex : this.messageIndex, + messageTotal : this.messageList.length, + } +}; + +AreaViewFSEModule.prototype.restoreSavedState = function(savedState) { + AreaViewFSEModule.super_.prototype.restoreSavedState.call(this, savedState); + + this.messageList = savedState.messageList; + this.messageIndex = savedState.messageIndex; + this.messageTotal = savedState.messageTotal; }; \ No newline at end of file