From 971079980e05f88527c5d5f253e3885d514889dc Mon Sep 17 00:00:00 2001 From: lilia Date: Tue, 14 Jul 2015 12:33:16 -0700 Subject: [PATCH] Close stale windows on background refresh All the old event listeners and in-memory objects have perished with the old background page. Also reopen the inbox if it was already open. Fixes #289 // FREEBIE --- js/background.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/js/background.js b/js/background.js index 57150b3d4d..5647de295c 100644 --- a/js/background.js +++ b/js/background.js @@ -22,6 +22,11 @@ }); chrome.alarms.create('awake', {periodInMinutes: 1}); } + var open = false; + chrome.app.window.getAll().forEach(function(appWindow) { + open = true; + appWindow.close(); + }); storage.fetch(); storage.onready(function() { @@ -52,6 +57,10 @@ // initialize the socket and start listening for messages messageReceiver = new textsecure.MessageReceiver(window); + + if (open) { + openInbox(); + } } function onContactReceived(ev) {