Skip to content

Commit

Permalink
Ej/fix persisted store (#746)
Browse files Browse the repository at this point in the history
* 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`
  • Loading branch information
lightlii committed Aug 22, 2023
1 parent ee47f41 commit 6769cd5
Showing 1 changed file with 5 additions and 14 deletions.
19 changes: 5 additions & 14 deletions src/renderer/hooks/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down

0 comments on commit 6769cd5

Please sign in to comment.