This commit is contained in:
Rizky 2024-02-04 16:08:48 +07:00
parent 7c69ee8509
commit 2301d94a0a
3 changed files with 8 additions and 14 deletions

View File

@ -154,7 +154,6 @@ export const EDGlobal = {
string,
{ entry: string[]; meta: Record<string, IMeta>; url: string }
>,
show_loading: false,
},
sync: null as unknown as Awaited<ReturnType<typeof clientStartSync>>,
site: deepClone(EmptySite),

View File

@ -35,7 +35,6 @@ export const edInitSync = (p: PG) => {
}
if (!params.page_id) {
if (location.pathname.startsWith("/vi/")) {
p.preview.show_loading = false;
if (page.list.length === 0) {
db.page
.findMany({

View File

@ -65,16 +65,7 @@ export const ViPreview = (arg: { pathname: string }) => {
viRoute(p);
if (p.status !== "ready") {
if (p.preview.show_loading) {
return <Loading note={p.status + "-page"} />;
} else {
setTimeout(() => {
p.preview.show_loading = true;
p.render();
}, 1000);
return null;
}
return <Loading note={p.status + "-page"} />;
}
const mode = p.mode;
@ -220,27 +211,32 @@ const viRoute = async (p: PG) => {
} else {
let page_cache = p.preview.meta_cache[params.page_id];
let should_render = false;
if (!page_cache) {
const idb_cache = await get(`page-${params.page_id}`, nav.store);
if (idb_cache) {
page_cache = idb_cache;
p.preview.meta_cache[params.page_id] = idb_cache;
should_render = true;
}
}
if (page_cache) {
if (page_cache && page_cache.entry.length > 0) {
p.page.meta = page_cache.meta;
p.page.entry = page_cache.entry;
if (p.page.cur.id !== params.page_id) {
p.page.cur = { id: params.page_id } as any;
}
p.status = "ready";
p.sync.page.load(params.page_id);
if (should_render) p.render();
return;
}
}
}
await reloadPage(p, params.page_id, "load-route");
}
}