From 6769cd520e9907ac1b573074a6b8c1ed70bef89c Mon Sep 17 00:00:00 2001 From: lightlii <32508751+lightlii@users.noreply.github.com> Date: Tue, 22 Aug 2023 10:49:23 +0200 Subject: [PATCH] Ej/fix persisted store (#746) * fix: restore setting persisted storage async * fix: make saved types in config consistent * fix: revert async await again (??) problem appears to be the format that's being saved (JSON or string) * fix: revert zustand serialisation stuf... persisted store working correctly now * fix: remove typings for `getItem`, `setItem`, and `removeItem` --- src/renderer/hooks/store.js | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/src/renderer/hooks/store.js b/src/renderer/hooks/store.js index 0a6d47bd..aebcc11c 100644 --- a/src/renderer/hooks/store.js +++ b/src/renderer/hooks/store.js @@ -7,24 +7,15 @@ import store from '../../persist-store' * @type {import('zustand/middleware').StateStorage} */ const storage = { - /** - * @param {string} key - A string key to reference the stored item by. - * @returns {string | null} - */ getItem: key => { - return /** @type {string | null} */ (store.get(key)) || null + /** + * @type {string | null} + */ + return store.get(key, null) }, - /** - * @param {string} key - A string key to reference the stored item by. - * @param {string} state - The state to be persisted - stringified JSON. - * @returns {void} - */ setItem: (key, state) => { - store.set(key, JSON.parse(state)) + store.set(key, state) }, - /** - * @param {string} key - A string key to reference the stored item to be removed. - */ removeItem: key => { store.delete(key) }