streaver / vue-preferences

The coolest and easiest way to manage your user's preferences on the client side with your preferred storage. Check out sample app here:
https://vue-preferences.netlify.com
MIT License
96 stars 3 forks source link

Additional quotes around strings #639

Open joshmakar opened 2 years ago

joshmakar commented 2 years ago

Describe the bug It seems like when a string value is stored, it's being stored with additional quotes around the string.

To Reproduce Steps to reproduce the behavior:

  1. Create the computed variable:
    computed: {
    applicationTheme: preference('applicationTheme', { defaultValue: 'default' }),
    }
  2. Set it to something:
    methods: {
    toggleDarkTheme() {
        this.applicationTheme = this.applicationTheme === 'default' ? 'dark' : 'default';
    }
    }
  3. Get the value from local storage (not using Vue/Vue-Preferences):
    const applicationTheme = localStorage.getItem("applicationTheme");
    // Value is equal to "default" or "dark", not default or dark

Expected behavior The value shouldn't be surrounded by quotes.

Screenshots image

Desktop (please complete the following information):

atalagorria commented 1 year ago

@joshmakar I don't think the issue is that the value is surrounded by quotes. Did you try to use the get() method to retrieve the value?

toggleDarkTheme() {
  const currentTheme = preference("applicationTheme").get();
  preference("applicationTheme").set(
    currentTheme === "default" ? "dark" : "default"
  );
},