fix
This commit is contained in:
parent
fab8bb24b5
commit
706048c882
|
|
@ -15,7 +15,6 @@ export const _ = {
|
||||||
|
|
||||||
let is_msgpack = req.query_parameters["msgpack"];
|
let is_msgpack = req.query_parameters["msgpack"];
|
||||||
|
|
||||||
console.log(is_msgpack);
|
|
||||||
if (validate(site_id)) {
|
if (validate(site_id)) {
|
||||||
const mode = is_msgpack ? "binary" : "string";
|
const mode = is_msgpack ? "binary" : "string";
|
||||||
const result = {
|
const result = {
|
||||||
|
|
|
||||||
File diff suppressed because one or more lines are too long
|
|
@ -2,8 +2,19 @@ import { get } from "idb-keyval";
|
||||||
import { IRoot } from "../../../utils/types/root";
|
import { IRoot } from "../../../utils/types/root";
|
||||||
import { base } from "./base";
|
import { base } from "./base";
|
||||||
|
|
||||||
|
const pendingPage = {} as Record<
|
||||||
|
string,
|
||||||
|
Promise<{
|
||||||
|
id: string;
|
||||||
|
url: string;
|
||||||
|
root: IRoot;
|
||||||
|
}>
|
||||||
|
>;
|
||||||
|
|
||||||
export const loadPage = (page_id: string) => {
|
export const loadPage = (page_id: string) => {
|
||||||
return new Promise<{
|
if (typeof pendingPage[page_id] === "object") return pendingPage[page_id];
|
||||||
|
|
||||||
|
pendingPage[page_id] = new Promise<{
|
||||||
id: string;
|
id: string;
|
||||||
url: string;
|
url: string;
|
||||||
root: IRoot;
|
root: IRoot;
|
||||||
|
|
@ -22,10 +33,18 @@ export const loadPage = (page_id: string) => {
|
||||||
id: string;
|
id: string;
|
||||||
url: string;
|
url: string;
|
||||||
root: IRoot;
|
root: IRoot;
|
||||||
|
content_tree?: IRoot;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (!res.root && res.content_tree) {
|
||||||
|
res.root = res.content_tree;
|
||||||
|
delete res.content_tree;
|
||||||
|
}
|
||||||
|
|
||||||
if (!returned) done(res);
|
if (!returned) done(res);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
return pendingPage[page_id];
|
||||||
};
|
};
|
||||||
|
|
||||||
export const loadPages = (page_ids: string[]) => {
|
export const loadPages = (page_ids: string[]) => {
|
||||||
|
|
@ -48,7 +67,7 @@ export const loadPages = (page_ids: string[]) => {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_done) {
|
if (is_done) {
|
||||||
done(result);
|
done(result);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,10 +7,11 @@ import { IMeta } from "../../vi/utils/types";
|
||||||
import { base } from "./base";
|
import { base } from "./base";
|
||||||
import { scanComponent } from "./component";
|
import { scanComponent } from "./component";
|
||||||
|
|
||||||
const cached = { route: null as any };
|
const cached = { route: null as any, promise: null as any };
|
||||||
|
|
||||||
const getRoute = () => {
|
const getRoute = () => {
|
||||||
return new Promise<{
|
if (cached.promise) return cached.promise;
|
||||||
|
cached.promise = new Promise<{
|
||||||
site: any;
|
site: any;
|
||||||
urls: {
|
urls: {
|
||||||
id: string;
|
id: string;
|
||||||
|
|
@ -19,10 +20,9 @@ const getRoute = () => {
|
||||||
layout: any;
|
layout: any;
|
||||||
}>(async (done) => {
|
}>(async (done) => {
|
||||||
if (cached.route) done(cached.route);
|
if (cached.route) done(cached.route);
|
||||||
|
|
||||||
let is_done = false;
|
|
||||||
|
|
||||||
let res = await fetch(base.url`_prasi/route`);
|
let is_done = false;
|
||||||
|
const res = await fetch(base.url`_prasi/route`);
|
||||||
if (!is_done) {
|
if (!is_done) {
|
||||||
if (!res.headers.get("content-encoding")) {
|
if (!res.headers.get("content-encoding")) {
|
||||||
fetch(base.url`_prasi/compress/only-gz`);
|
fetch(base.url`_prasi/compress/only-gz`);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue