From b09e3284638b849acfdb7718f95af38c1e85c0d7 Mon Sep 17 00:00:00 2001 From: David Cormier Date: Fri, 21 Feb 2014 08:54:17 -0500 Subject: [PATCH] Reinitialize context when relay closes connection Fixes #73 --- js/glowingbear.js | 6 ++++++ js/models.js | 8 ++++++++ 2 files changed, 14 insertions(+) diff --git a/js/glowingbear.js b/js/glowingbear.js index 2160e04..d60b1de 100644 --- a/js/glowingbear.js +++ b/js/glowingbear.js @@ -378,6 +378,7 @@ function($rootScope, $log.info("Disconnected from relay"); failCallbacks('disconnection'); $rootScope.connected = false; + $rootScope.$emit('relayDisconnect'); $rootScope.$apply(); }; @@ -578,6 +579,11 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout', }); $scope.buffers = models.model.buffers; + + $rootScope.$on('relayDisconnect', function() { + models.reinitialize(); + }); + $scope.activeBuffer = models.getActiveBuffer; $rootScope.waseverconnected = false; diff --git a/js/models.js b/js/models.js index e17a936..a222a52 100644 --- a/js/models.js +++ b/js/models.js @@ -425,6 +425,14 @@ models.service('models', ['$rootScope', '$filter', function($rootScope, $filter) return BufferList; }; + /* + * Reinitializes the model + */ + this.reinitialize = function() { + BufferList = []; + this.model.buffers = {}; + }; + /* * Returns a specific buffer object *