Skip to content
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

Dont work in Firefox, after extension is reloaded #31

Closed
Rightusername opened this issue May 25, 2020 · 3 comments
Closed

Dont work in Firefox, after extension is reloaded #31

Rightusername opened this issue May 25, 2020 · 3 comments
Labels
bug Something isn't working

Comments

@Rightusername
Copy link

Rightusername commented May 25, 2020

Firefox version: 76.0.1
OS: windows 10 64-bit

import Vue from 'vue';
import Vuex from 'vuex';
import VuexWebExtensions from 'vuex-webextensions';

import { STORAGE } from './../background/storage';

Vue.use(Vuex);

export default new Vuex.Store({
  plugins: [
    VuexWebExtensions({
      persistentStates: ['storage'],
      ignoredMutations: ['SET_CLOCK'],
      syncActions: false,
      loggerLevel: 'debug',
    }),
  ],
  state: {
    storage: STORAGE,
    isClock: false,
  },

...

After reloading extension or turn off/on, "storage" object is undefined
In Chrome and Edge it works fine

@RomainLK
Copy link

I had to investigate this for my extension and I have found that the function browser.storage.local.set of Firefox doesn't work properly when giving the state of the store. I think it just doesn't support the proxy which Vue uses for the reactivity of its object. My solution was to modify the library and add a JSON.stringify followed by JSON.parse

browser.js:

else if (this.browser == browsers.firefox) {
      try {
        browser.storage.local.set({
          '@@vwe-persistence': JSON.parse(JSON.stringify(datas))
        });
      } catch (err) {
        Logger.error(`Can't write persistent states to local storage. Did you grant storage permission to your WebExtension?`);
      }
    

@MitsuhaKitsune
Copy link
Owner

I should investigate it, on the past, I remove any extra serialization because Firefox handle it automatically and just do redundant steps decreasing the performance of the plugin.

@MitsuhaKitsune MitsuhaKitsune added the bug Something isn't working label Aug 4, 2021
@MitsuhaKitsune
Copy link
Owner

On my investigation, seems related with issue #29, I still debugging and trying to fix this, we continue this on issue #29

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants