From 3520b84d83e7712dcf28d6a62b98c7d2a0cec91c Mon Sep 17 00:00:00 2001 From: Nick Krichevsky Date: Sat, 21 Feb 2015 21:39:21 -0500 Subject: [PATCH] Add communication in order to rememdy bug where window names were overwritten --- background.js | 10 +++++++++- popup.js | 1 + 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/background.js b/background.js index d15c663..dfcc120 100644 --- a/background.js +++ b/background.js @@ -166,6 +166,14 @@ chrome.tabs.onAttached.addListener(function(tabId,objects){ } }); +chrome.runtime.onMessage.addListener(function(response){ + if (response.hasOwnProperty('nameChange')){ + var currentWindow = findWindowById(response.nameChange.windowId); + currentWindow.window.name = response.nameChange.name; + saveWindows(); + } +}); + //init chrome.storage.local.get('windows',function(result){ console.log(result); @@ -176,4 +184,4 @@ clearStorage(function(){ createWindowStorage(function(){ populateWindowStorage(); }); -}); \ No newline at end of file +}); diff --git a/popup.js b/popup.js index 20b94c1..a659267 100644 --- a/popup.js +++ b/popup.js @@ -15,6 +15,7 @@ function changeWindowName(windowId,newName,callback){ if (changedWindow.length===1){ changedWindow[0].name = newName; chrome.storage.local.set({"windows":windows},callback); + chrome.runtime.sendMessage({'nameChange':{'windowId':windowId,'name':newName}}); } else{ throw "More than one window has the id "+windowId+". This should never happen."