Simplify panel state management and message passing

This commit is contained in:
Riley Shaw 2015-01-21 18:27:42 -10:00 committed by lilia
parent 9071d98395
commit 94ce4d4b91
12 changed files with 148 additions and 102 deletions

View file

@ -223,13 +223,12 @@
});
};
extension.on('log', console.log.bind(console));
var windowMap = Whisper.windowMap = new Whisper.Bimap('windowId', 'modelId');
chrome.runtime.onConnect.addListener(function (port) {
if (port.name === 'panel_presence') {
port.onDisconnect.addListener(function (message) {
closeConversation(message.sender.tab.windowId);
});
// make sure panels are cleaned up on close
chrome.windows.onRemoved.addListener(function (windowId) {
if (windowMap.windowId[windowId]) {
closeConversation(windowId);
}
});