Reinitialize context when relay closes connection

Fixes #73
This commit is contained in:
David Cormier 2014-02-21 08:54:17 -05:00
parent 0deb14fc84
commit b09e328463
2 changed files with 14 additions and 0 deletions

View file

@ -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;

View file

@ -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
*