feat: user prompts

This commit is contained in:
Yidadaa
2023-04-18 01:34:12 +08:00
parent fdc8278b90
commit 789a779775
14 changed files with 269 additions and 37 deletions

View File

@@ -50,13 +50,16 @@ export const useUpdateStore = create<UpdateStore>()(
const overTenMins = Date.now() - get().lastUpdate > 10 * ONE_MINUTE;
if (!force && !overTenMins) return;
set(() => ({
lastUpdate: Date.now(),
}));
try {
// const data = await (await fetch(FETCH_TAG_URL)).json();
// const remoteId = data[0].name as string;
const data = await (await fetch(FETCH_COMMIT_URL)).json();
const remoteId = (data[0].sha as string).substring(0, 7);
set(() => ({
lastUpdate: Date.now(),
remoteVersion: remoteId,
}));
console.log("[Got Upstream] ", remoteId);
@@ -69,6 +72,10 @@ export const useUpdateStore = create<UpdateStore>()(
const overOneMinute = Date.now() - get().lastUpdateUsage >= ONE_MINUTE;
if (!overOneMinute && !force) return;
set(() => ({
lastUpdateUsage: Date.now(),
}));
const usage = await requestUsage();
if (usage) {