refactor: ♻️ force patrons update on about-calckey
This commit is contained in:
parent
8103dd82ec
commit
6fbe508403
2 changed files with 11 additions and 5 deletions
|
@ -11,19 +11,25 @@ export const meta = {
|
||||||
|
|
||||||
export const paramDef = {
|
export const paramDef = {
|
||||||
type: "object",
|
type: "object",
|
||||||
properties: {},
|
properties: {
|
||||||
|
forceUpdate: { type: "boolean", default: false },
|
||||||
|
},
|
||||||
required: [],
|
required: [],
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
export default define(meta, paramDef, async () => {
|
export default define(meta, paramDef, async (ps) => {
|
||||||
let patrons;
|
let patrons;
|
||||||
const cachedPatrons = await redisClient.get("patrons");
|
const cachedPatrons = await redisClient.get("patrons");
|
||||||
if (cachedPatrons) {
|
if (!ps.forceUpdate && cachedPatrons) {
|
||||||
patrons = JSON.parse(cachedPatrons);
|
patrons = JSON.parse(cachedPatrons);
|
||||||
} else {
|
} else {
|
||||||
patrons = await fetch(
|
patrons = await fetch(
|
||||||
"https://codeberg.org/calckey/calckey/raw/branch/develop/patrons.json",
|
"https://codeberg.org/calckey/calckey/raw/branch/develop/patrons.json",
|
||||||
).then((response) => response.json());
|
)
|
||||||
|
.then((response) => response.json())
|
||||||
|
.catch(() => {
|
||||||
|
patrons = cachedPatrons ? JSON.parse(cachedPatrons) : [];
|
||||||
|
});
|
||||||
await redisClient.set("patrons", JSON.stringify(patrons), "EX", 3600);
|
await redisClient.set("patrons", JSON.stringify(patrons), "EX", 3600);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -164,7 +164,7 @@ import { defaultStore } from "@/store";
|
||||||
import * as os from "@/os";
|
import * as os from "@/os";
|
||||||
import { definePageMetadata } from "@/scripts/page-metadata";
|
import { definePageMetadata } from "@/scripts/page-metadata";
|
||||||
|
|
||||||
const patrons = await os.api("patrons");
|
const patrons = await os.api("patrons", { forceUpdate: true });
|
||||||
|
|
||||||
let easterEggReady = false;
|
let easterEggReady = false;
|
||||||
let easterEggEmojis = $ref([]);
|
let easterEggEmojis = $ref([]);
|
||||||
|
|
Loading…
Reference in a new issue