Fix: Attempt to Improve UI-Login Cache (#63)

This commit is contained in:
Youwes09
2026-05-03 12:29:20 -05:00
parent 093b395cc1
commit 0d53e3f102
8 changed files with 58 additions and 42 deletions
+9 -13
View File
@@ -1,6 +1,7 @@
import { store } from "@store/state.svelte";
import { fetchAuthenticated, AuthRequiredError, uiAuth } from "../core/auth";
import { boot } from "@store/boot.svelte";
import { getBlobUrl } from "@core/cache/imageCache";
const DEFAULT_URL = "http://127.0.0.1:4567";
@@ -25,20 +26,15 @@ export function getServerUrl(): string {
export function plainThumbUrl(path: string): string {
if (!path) return "";
if (path.startsWith("http")) return path;
const base = `${getServerUrl()}${path}`;
return `${getServerUrl()}${path}`;
}
export async function resolveImageUrl(path: string): Promise<string> {
if (!path) return "";
const url = path.startsWith("http") ? path : `${getServerUrl()}${path}`;
const mode = store.settings.serverAuthMode ?? "NONE";
if (mode === "UI_LOGIN") {
const token = uiAuth.getToken();
if (token) {
const url = new URL(base);
url.searchParams.set("authorization", token);
return url.toString();
}
}
return base;
if (mode === "NONE") return url;
return getBlobUrl(url);
}
export const thumbUrl = plainThumbUrl;