Skip to content

Double patching for state when extension is opened in a separate tab #312

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions src/wrap-store/wrapStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,12 +136,17 @@ export default ({ channelName = defaultOpts.channelName } = defaultOpts) => {
};

browserAPI.runtime.sendMessage(...args, onErrorCallback);

/*
* With this approach, if you open the extension in a new tab, we will patch the state twice.
* We still do not use redux for content scripts, so we can rework this code only if necessary.
*/
// We will broadcast state changes to all tabs to sync state across content scripts
return browserAPI.tabs.query({}, (tabs) => {
for (const tab of tabs) {
browserAPI.tabs.sendMessage(tab.id, ...args, onErrorCallback);
}
});
// return browserAPI.tabs.query({}, (tabs) => {
// for (const tab of tabs) {
// browserAPI.tabs.sendMessage(tab.id, ...args, onErrorCallback);
// }
// });
});

let currentState = store.getState();
Expand Down