fix: loading speeds

This commit is contained in:
fn
2026-04-17 11:27:21 +01:00
parent c08e5e986f
commit 3f059905d8
3 changed files with 39 additions and 13 deletions

View File

@@ -113,14 +113,24 @@ const getLatestManifestFromAo = async (): Promise<string | null> => {
};
export const loadManifest = async (): Promise<ManifestPost[]> => {
const manifestTxId = (await getLatestManifestFromAo()) ?? MANIFEST_TX_ID;
const response = await fetch(arweaveUrl(manifestTxId));
if (!response.ok) {
throw new Error(`Failed to load manifest (${response.status})`);
}
const loadByTxId = async (manifestTxId: string): Promise<ManifestPost[]> => {
const response = await fetch(arweaveUrl(manifestTxId));
if (!response.ok) {
throw new Error(`Failed to load manifest (${response.status})`);
}
const payload: unknown = await response.json();
return parseManifest(payload);
};
const payload: unknown = await response.json();
return parseManifest(payload);
try {
return await loadByTxId(MANIFEST_TX_ID);
} catch (manifestError) {
const latestManifestTxId = await getLatestManifestFromAo();
if (!latestManifestTxId || latestManifestTxId === MANIFEST_TX_ID) {
throw manifestError;
}
return loadByTxId(latestManifestTxId);
}
};
const isObject = (value: unknown): value is Record<string, unknown> =>