MCPcopy Create free account
hub / github.com/hashintel/hash / setInLocalStorage

Function setInLocalStorage

apps/plugin-browser/src/shared/storage.ts:216–237  ·  view source on GitHub ↗
(
  key: Key,
  value: LocalStorage[Key],
  skipDbPersist = false,
)

Source from the content-addressed store, hash-verified

214 * Set a value in local storage. Also syncs some values to the database.
215 */
216export const setInLocalStorage = async <Key extends keyof LocalStorage>(
217 key: Key,
218 value: LocalStorage[Key],
219 skipDbPersist = false,
220) => {
221 await browser.storage.local.set({ [key]: value });
222
223 if (key === "automaticInferenceConfig") {
224 if ((value as LocalStorage["automaticInferenceConfig"]).enabled) {
225 setEnabledBadge();
226 } else {
227 setDisabledBadge();
228 }
229 }
230
231 /**
232 * Persist local storage state to the database where we want to preserve state across devices/browsers/log-outs
233 */
234 if (!skipDbPersist && isDbPersistedSetting(key)) {
235 await debouncedEntityUpdate();
236 }
237};
238
239type ReplaceFromLocalStorageValue<Key extends keyof LocalStorage> = (
240 currentValue: LocalStorage[Key] | undefined,

Callers 4

useStorageSyncFunction · 0.90
background.tsFile · 0.90
getUserFunction · 0.90

Calls 4

setEnabledBadgeFunction · 0.90
setDisabledBadgeFunction · 0.90
isDbPersistedSettingFunction · 0.85
setMethod · 0.45

Tested by

no test coverage detected