Skip to content

Commit

Permalink
feat: save settings locally
Browse files Browse the repository at this point in the history
Re RM:27156
Re #418
  • Loading branch information
cristinecula committed Oct 15, 2021
1 parent c20f994 commit b790aaa
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions lib/use-saved-settings.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { useCallback, useMemo, useState } from 'haunted';
import { omit } from '@neovici/cosmoz-utils/lib/object';

const
storagePrefix = 'omnitable-',
drop = keys => item => Object.fromEntries(Object.entries(item).filter(([key]) => !keys.includes(key)));
const storagePrefix = 'omnitable-';

export const useSavedSettings = (settingsId, settings, setSettings) => {
const
Expand All @@ -28,7 +27,7 @@ export const useSavedSettings = (settingsId, settings, setSettings) => {
}

try {
localStorage.setItem(storagePrefix + settingsId, JSON.stringify(settings.map(drop(['title', 'minWidth']))));
localStorage.setItem(storagePrefix + settingsId, JSON.stringify(settings.map(omit(['title', 'minWidth']))));
setSettings([]);
setCounter(counter => counter + 1);
} catch (e) {
Expand Down

0 comments on commit b790aaa

Please sign in to comment.