Skip to content

Commit

Permalink
Update condition for updating newUpdates count
Browse files Browse the repository at this point in the history
  • Loading branch information
mohdsayed committed Feb 3, 2024
1 parent f6472a8 commit d051f50
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion packages/extension/src/store/synchnorousCookieStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,7 @@ class SynchnorousCookieStore {
removeCookieData(tabId: number) {
delete this.tabsData[tabId];
this.tabsData[tabId] = {};
this.tabs[tabId].newUpdates = 0;
this.sendUpdatedDataToPopupAndDevTools(tabId);
}

Expand Down Expand Up @@ -355,11 +356,15 @@ class SynchnorousCookieStore {
tabId: number,
overrideForInitialSync = false
) {
let sentMessageAnyWhere = false;

try {
if (
this.tabs[tabId].devToolsOpenState &&
(overrideForInitialSync || this.tabs[tabId].newUpdates > 0)
) {
sentMessageAnyWhere = true;

await chrome.runtime.sendMessage({
type: 'ServiceWorker::DevTools::NEW_COOKIE_DATA',
payload: {
Expand All @@ -373,6 +378,7 @@ class SynchnorousCookieStore {
this.tabs[tabId].popupOpenState &&
(overrideForInitialSync || this.tabs[tabId].newUpdates > 0)
) {
sentMessageAnyWhere = true;
await chrome.runtime.sendMessage({
type: 'ServiceWorker::Popup::NEW_COOKIE_DATA',
payload: {
Expand All @@ -385,7 +391,10 @@ class SynchnorousCookieStore {
// eslint-disable-next-line no-console
console.warn(error);
}
this.tabs[tabId].newUpdates = 0;

if (sentMessageAnyWhere) {
this.tabs[tabId].newUpdates = 0;
}
}
}

Expand Down

0 comments on commit d051f50

Please sign in to comment.