fix(cloud PFP): Not pulling from cloud on page load

This commit is contained in:
2026-06-25 18:36:57 +09:30
parent c9b9ad250e
commit 670f9d73f3
5 changed files with 249 additions and 67 deletions
+8
View File
@@ -28,6 +28,10 @@ export function pfpUrlWithHash(url: string, hash: string | null | undefined): st
return `${base}?v=${hash}`;
}
export function defaultAccountsPfpUrl(userId: string): string {
return `${ACCOUNTS_BASE}/api/user/pfp/${userId}`;
}
async function fetchServerHash(userId: string): Promise<string | null> {
const res = await fetch(`${ACCOUNTS_BASE}/api/user/pfp/${userId}/meta`);
if (!res.ok) return null;
@@ -95,6 +99,10 @@ export async function resolveCloudPfp(
if (localHash) {
headers["If-None-Match"] = `"${localHash}"`;
}
const token = await cloudAuth.getStoredToken();
if (token && isAccountsHostedPfpUrl(pfpUrl)) {
headers.Authorization = `Bearer ${token}`;
}
const res = await fetch(imageUrl, { headers });
if (res.status === 304 && localBlob instanceof Blob) {