fix(rates): reduce cache TTL, expose fallback header and show stale data warning

This commit is contained in:
2026-03-09 18:17:01 +01:00
parent 1f86a5ead4
commit 10493826bf
4 changed files with 31 additions and 6 deletions

View File

@@ -243,6 +243,24 @@ export function ConverterCard({
}
};
const displayUpdatedAt = useMemo(() => {
if (!data) {
return null;
}
const timestamps = [new Date(data.updatedAt).getTime()];
if (marketData?.updatedAt) {
timestamps.push(new Date(marketData.updatedAt).getTime());
}
const latest = Math.max(
...timestamps.filter((timestamp) => Number.isFinite(timestamp)),
);
return Number.isFinite(latest) ? new Date(latest).toISOString() : data.updatedAt;
}, [data, marketData?.updatedAt]);
if (isLoading && !data) {
return <ConverterSkeleton />;
}
@@ -497,7 +515,7 @@ export function ConverterCard({
<div>
<p className="text-xs uppercase tracking-[0.12em]">Last updated</p>
<p className="mt-1 text-sm text-foreground">
{formatTimestamp(data.updatedAt)}
{formatTimestamp(displayUpdatedAt ?? data.updatedAt)}
</p>
</div>
</div>