PeterBlenessy / ai-assistant-for-jira-desktop

0 stars 0 forks source link

Fix Pinia store issues #12

Closed PeterBlenessy closed 1 week ago

PeterBlenessy commented 1 week ago

The Pinia store implemented is wrong.

This is an example of a good implementation:

import { ref, watch } from "vue"; import { defineStore } from "pinia";

export const usePersistedStore = defineStore("persisted-store", () => {

const apiKey = ref(loadStateFromLocalStorage("apiKey") || "");

function saveStateToLocalStorage(key, value) {
    localStorage.setItem(key, JSON.stringify(value));
}

function loadStateFromLocalStorage(key) {
    const value = localStorage.getItem(key);
    return value ? JSON.parse(value) : null;
}

watch(apiKey, (newValue) => {
    saveStateToLocalStorage("apiKey", newValue);
});

return {
    apiKey,

};

});

PeterBlenessy commented 1 week ago

Also, rename the application store from index.js to settings-store.js

PeterBlenessy commented 1 week ago

Also, rename the folder src/store to src/stores