From 5fd0b46756439ce96c4bb06a882a0069a18fba7c Mon Sep 17 00:00:00 2001 From: Manav Rathi Date: Thu, 5 Sep 2024 15:58:15 +0530 Subject: [PATCH] Remove legacy apiOrigin migration > "Note that the legacy value was never in production builds, only nightlies, so this code can be removed soon" --- web/packages/base/origins.ts | 22 +++++-------------- .../new/photos/components/DevSettings.tsx | 18 +-------------- 2 files changed, 6 insertions(+), 34 deletions(-) diff --git a/web/packages/base/origins.ts b/web/packages/base/origins.ts index 8c39396fb2..d1474014a3 100644 --- a/web/packages/base/origins.ts +++ b/web/packages/base/origins.ts @@ -1,5 +1,4 @@ -import { getKV, setKV } from "@/base/kv"; -import { inWorker } from "./env"; +import { getKV } from "@/base/kv"; /** * Return the origin (scheme, host, port triple) that should be used for making @@ -35,21 +34,10 @@ export const apiURL = async (path: string) => (await apiOrigin()) + path; * * Otherwise return undefined. */ -export const customAPIOrigin = async () => { - let origin = await getKV("apiOrigin"); - if (!origin && !inWorker()) { - // TODO: Migration of apiOrigin from local storage to indexed DB. Added - // 27 June 2024, 1.7.2-rc. Remove me after a bit (tag: Migration). - const legacyOrigin = localStorage.getItem("apiOrigin"); - if (legacyOrigin !== null) { - origin = legacyOrigin; - if (origin) await setKV("apiOrigin", origin); - localStorage.removeItem("apiOrigin"); - } - } - - return origin ?? process.env.NEXT_PUBLIC_ENTE_ENDPOINT ?? undefined; -}; +export const customAPIOrigin = async () => + (await getKV("apiOrigin")) ?? + process.env.NEXT_PUBLIC_ENTE_ENDPOINT ?? + undefined; /** * A convenience wrapper over {@link customAPIOrigin} that returns the only the diff --git a/web/packages/new/photos/components/DevSettings.tsx b/web/packages/new/photos/components/DevSettings.tsx index 2e3b1b3978..33da3a7373 100644 --- a/web/packages/new/photos/components/DevSettings.tsx +++ b/web/packages/new/photos/components/DevSettings.tsx @@ -69,17 +69,7 @@ const Contents: React.FC = (props) => { >(); useEffect( - () => - void getKV("apiOrigin").then((o) => - setInitialAPIOrigin( - // Migrate apiOrigin from local storage to indexed DB. - // - // This code was added 27 June 2024. Note that the legacy - // value was never in production builds, only nightlies, so - // this code can be removed soon (tag: Migration). - o ?? localStorage.getItem("apiOrigin") ?? "", - ), - ), + () => void getKV("apiOrigin").then((o) => setInitialAPIOrigin(o ?? "")), [], ); @@ -219,12 +209,6 @@ const Form: React.FC = ({ initialAPIOrigin, onClose }) => { const updateAPIOrigin = async (origin: string) => { if (!origin) { await removeKV("apiOrigin"); - // Migrate apiOrigin from local storage to indexed DB. - // - // This code was added 27 June 2024. Note that the legacy value was - // never in production builds, only nightlies, so this code can be - // removed at some point soon (tag: Migration). - localStorage.removeItem("apiOrigin"); return; }