Skip to content

Commit 4221d69

Browse files
authored
Merge pull request #12 from react-hook-form/fix-popup
Cleanup cache only when page reload
2 parents b555d58 + e2016a8 commit 4221d69

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

public/manifest.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
"<all_urls>"
3838
],
3939
"permissions": [
40-
"tabs"
40+
"tabs",
41+
"webNavigation"
4142
]
42-
}
43+
}

src/background.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,16 @@ const cleanupCache = (tabId: number) => {
1616
}
1717
};
1818

19+
chrome.webNavigation.onCommitted.addListener(({ transitionType, tabId }) => {
20+
if (transitionType === 'reload') {
21+
cleanupCache(tabId);
22+
}
23+
});
24+
1925
chrome.tabs.onUpdated.addListener((tabId) => {
20-
cleanupCache(tabId);
2126
addExtensionMessageListener((message) => {
2227
switch (message.type) {
2328
case 'WELCOME': {
24-
enabledTab.add(tabId);
2529
chrome.action.setIcon({
2630
tabId,
2731
path: {
@@ -31,6 +35,7 @@ chrome.tabs.onUpdated.addListener((tabId) => {
3135
128: 'images/icon128.png',
3236
},
3337
});
38+
enabledTab.add(tabId);
3439
break;
3540
}
3641
case 'UPDATE': {

0 commit comments

Comments
 (0)