From 13c5f3c2526b60b37a190603cc4ba75c1d7e3307 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=E2=9D=A4=EF=B8=8F=20=E2=98=AE=EF=B8=8F=20=E2=9C=8B?= <6723574+louisgv@users.noreply.github.com> Date: Wed, 19 Jun 2024 03:16:38 +0700 Subject: [PATCH] chore: prettier --- src/hook.ts | 10 ++++------ src/index.ts | 10 +++++----- src/utils.ts | 2 +- 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/src/hook.ts b/src/hook.ts index 9da5abe..c6097f6 100644 --- a/src/hook.ts +++ b/src/hook.ts @@ -15,9 +15,9 @@ type Setter = ((v?: T, isHydrated?: boolean) => T) | T export type RawKey = | string | { - key: string - instance: BaseStorage - } + key: string + instance: BaseStorage + } /** * https://docs.plasmo.com/framework/storage @@ -54,12 +54,10 @@ export function useStorage(rawKey: RawKey, onInit?: Setter) { const key = isObjectKey ? rawKey.key : rawKey - const [isLoading, setIsLoading] = useState(true); - // Render state const [renderValue, setRenderValue] = useState(onInit) const [isLoading, setIsLoading] = useState(true) - + // Use to ensure we don't set render state after unmounted const isMounted = useRef(false) diff --git a/src/index.ts b/src/index.ts index 03fec66..f9fbbd1 100644 --- a/src/index.ts +++ b/src/index.ts @@ -25,7 +25,7 @@ export type StorageArea = chrome.storage.StorageArea export type InternalStorage = typeof chrome.storage export type SerdeOptions = { - serializer: (value: T) => string, + serializer: (value: T) => string deserializer: (rawValue: string) => T } @@ -120,7 +120,7 @@ export abstract class BaseStorage { if (this.hasWebApi && (allCopied || copiedKeyList.length > 0)) { this.#secondaryClient = window.localStorage } - } catch { } + } catch {} try { if (this.hasExtensionApi) { @@ -135,7 +135,7 @@ export abstract class BaseStorage { this.#primaryClient = this.#extStorageEngine[this.area] } } - } catch { } + } catch {} } setCopiedKeySet(keyList: string[]) { @@ -175,8 +175,8 @@ export abstract class BaseStorage { const dataMap = this.allCopied ? await this.rawGetAll() : await this.#primaryClient.get( - (syncAll ? [...this.copiedKeySet] : [key]).map(this.getNamespacedKey) - ) + (syncAll ? [...this.copiedKeySet] : [key]).map(this.getNamespacedKey) + ) if (!dataMap) { return false diff --git a/src/utils.ts b/src/utils.ts index 87dd9e1..9082d16 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -11,7 +11,7 @@ export const isChromeBelow100 = () => { return ( parseInt(browserMatch[2]) < 100 || globalThis.chrome.runtime?.getManifest()?.manifest_version === 2 - ); + ) } } catch { return false