Closed KBoyarchuk closed 6 years ago
Confirm that, I have similar issue with content script...
This is caused because the messaging api, it have a bit of delay, for now the workarround its delay a bit your initialization to let the plugin sync the state with the background store first and then commit your mutations.
To avoid this, I think on a "pending queue", before STORE_INITIAL_STATE queue all mutations and when the state are synced with the backgrond apply all of them.
How you see this method? Any ideas to improve it?
Should be fixed with https://github.com/MitsuhaKitsune/vuex-webextensions/commit/4387b5d02e394b721e1e3726fcfbe70d0df36dee, available on npm as v1.2.3, try it and give me feedback please
Create PR. Check it please.
Finally fixed the initialization on content scripts? :)
Yeap. At the moment everything works stably.
In contentScripts.js file there may be a problem. When we first open the extension popup, function sendMutation called before onMessage listener. In this case, when the data is written to the state, the onMessage handler is called with type STORE_INITIAL_STATE and the replaceState method overwrites the data that was previous written to the state.
As example: