Avoid search cache loading flicker

This commit is contained in:
TerryM
2026-05-28 23:17:49 +08:00
parent 320739f91b
commit f7828d8776

View File

@@ -83,7 +83,7 @@ export function SearchPanel({
const cachedTags = readJSONCache<PostListResponse>(tagsUrl); const cachedTags = readJSONCache<PostListResponse>(tagsUrl);
if (cachedTags) setTags(extractTags(itemsOrEmpty(cachedTags.items))); if (cachedTags) setTags(extractTags(itemsOrEmpty(cachedTags.items)));
setIsTagLoading(true); setIsTagLoading(!cachedTags);
getJSON<PostListResponse>(tagsUrl) getJSON<PostListResponse>(tagsUrl)
.then((res) => { .then((res) => {
if (cancelled) return; if (cancelled) return;
@@ -118,7 +118,7 @@ export function SearchPanel({
); );
} }
setIsPostLoading(true); setIsPostLoading(!cachedPosts);
getJSON<PostListResponse>(searchUrl) getJSON<PostListResponse>(searchUrl)
.then((res) => { .then((res) => {
const exactMatches = itemsOrEmpty(res.items).filter((post) => const exactMatches = itemsOrEmpty(res.items).filter((post) =>