Skip to content

Commit 3a2df72

Browse files
committed
Fixed tabState reseting bug
1 parent df2ab71 commit 3a2df72

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

src/background/BackgroundScript.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@
44

55
module BackgroundScript {
66
var tabStates;
7+
78
export function getTabStateManager() {
89
return tabStates;
910
}
11+
1012
function init() {
1113
tabStates = new TabStateManager();
1214
addTabStateListeners(tabStates);
@@ -32,10 +34,9 @@ module BackgroundScript {
3234
var id = sender.tab.id;
3335
// Reset the tab state whenever it is loaded/reloaded
3436
if (request.event == "loaded") {
35-
if (tabStates.exists(id)) {
37+
if (!tabStates.exists(id)) { // New tab
3638
tabStates.resetState(id);
37-
} else {
38-
// Don't change the query, only reset searching
39+
} else { // Same tab, refresh or new URL
3940
tabStates.set(id, "searching", false);
4041
}
4142
}

src/popup/popup.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ module Popup {
88
var tabStates = BackgroundInterface.getTabStateManager();
99

1010
// In most cases the map entry will already be initialized. However, there
11-
// may be a few edge cases where we need to initialize it ourselves.
11+
// may be a few edge cases where we need to initialize it ourselves,
12+
// like if we enable/reload the extension
1213
if (!tabStates.exists(id)) {
1314
Utils.log("ID doesn't exist. Initializing entry.")
1415
tabStates.resetState(id);

0 commit comments

Comments
 (0)