Remove legacy apiOrigin migration
> "Note that the legacy value was never in production builds, only nightlies, so this code can be removed soon"
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -69,17 +69,7 @@ const Contents: React.FC<ContentsProps> = (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<FormProps> = ({ 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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user