wip fix
This commit is contained in:
parent
7c69ee8509
commit
2301d94a0a
|
|
@ -154,7 +154,6 @@ export const EDGlobal = {
|
||||||
string,
|
string,
|
||||||
{ entry: string[]; meta: Record<string, IMeta>; url: string }
|
{ entry: string[]; meta: Record<string, IMeta>; url: string }
|
||||||
>,
|
>,
|
||||||
show_loading: false,
|
|
||||||
},
|
},
|
||||||
sync: null as unknown as Awaited<ReturnType<typeof clientStartSync>>,
|
sync: null as unknown as Awaited<ReturnType<typeof clientStartSync>>,
|
||||||
site: deepClone(EmptySite),
|
site: deepClone(EmptySite),
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,6 @@ export const edInitSync = (p: PG) => {
|
||||||
}
|
}
|
||||||
if (!params.page_id) {
|
if (!params.page_id) {
|
||||||
if (location.pathname.startsWith("/vi/")) {
|
if (location.pathname.startsWith("/vi/")) {
|
||||||
p.preview.show_loading = false;
|
|
||||||
if (page.list.length === 0) {
|
if (page.list.length === 0) {
|
||||||
db.page
|
db.page
|
||||||
.findMany({
|
.findMany({
|
||||||
|
|
|
||||||
|
|
@ -65,16 +65,7 @@ export const ViPreview = (arg: { pathname: string }) => {
|
||||||
viRoute(p);
|
viRoute(p);
|
||||||
|
|
||||||
if (p.status !== "ready") {
|
if (p.status !== "ready") {
|
||||||
if (p.preview.show_loading) {
|
return <Loading note={p.status + "-page"} />;
|
||||||
return <Loading note={p.status + "-page"} />;
|
|
||||||
} else {
|
|
||||||
setTimeout(() => {
|
|
||||||
p.preview.show_loading = true;
|
|
||||||
p.render();
|
|
||||||
}, 1000);
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const mode = p.mode;
|
const mode = p.mode;
|
||||||
|
|
@ -220,27 +211,32 @@ const viRoute = async (p: PG) => {
|
||||||
} else {
|
} else {
|
||||||
let page_cache = p.preview.meta_cache[params.page_id];
|
let page_cache = p.preview.meta_cache[params.page_id];
|
||||||
|
|
||||||
|
let should_render = false;
|
||||||
if (!page_cache) {
|
if (!page_cache) {
|
||||||
const idb_cache = await get(`page-${params.page_id}`, nav.store);
|
const idb_cache = await get(`page-${params.page_id}`, nav.store);
|
||||||
if (idb_cache) {
|
if (idb_cache) {
|
||||||
page_cache = idb_cache;
|
page_cache = idb_cache;
|
||||||
p.preview.meta_cache[params.page_id] = 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.meta = page_cache.meta;
|
||||||
p.page.entry = page_cache.entry;
|
p.page.entry = page_cache.entry;
|
||||||
|
|
||||||
if (p.page.cur.id !== params.page_id) {
|
if (p.page.cur.id !== params.page_id) {
|
||||||
p.page.cur = { id: params.page_id } as any;
|
p.page.cur = { id: params.page_id } as any;
|
||||||
}
|
}
|
||||||
|
|
||||||
p.status = "ready";
|
p.status = "ready";
|
||||||
|
p.sync.page.load(params.page_id);
|
||||||
|
if (should_render) p.render();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
await reloadPage(p, params.page_id, "load-route");
|
await reloadPage(p, params.page_id, "load-route");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue