mirror of
https://github.com/Yidadaa/ChatGPT-Next-Web.git
synced 2025-08-08 02:04:43 +08:00
refactor: #6 check update over one hour and debound scroll
This commit is contained in:
21
app/utils.ts
21
app/utils.ts
@@ -74,24 +74,3 @@ export function getCurrentCommitId() {
|
||||
|
||||
return currentId;
|
||||
}
|
||||
|
||||
let remoteId: string;
|
||||
export async function checkUpstreamLatestCommitId(force = false) {
|
||||
if (!force && remoteId) {
|
||||
return remoteId;
|
||||
}
|
||||
|
||||
const owner = "Yidadaa";
|
||||
const repo = "ChatGPT-Next-Web";
|
||||
const url = `https://api.github.com/repos/${owner}/${repo}/commits?per_page=1`;
|
||||
|
||||
try {
|
||||
const data = await (await fetch(url)).json();
|
||||
const sha = data[0].sha as string;
|
||||
remoteId = sha.substring(0, 7);
|
||||
return remoteId;
|
||||
} catch (error) {
|
||||
console.error("[Fetch Upstream Commit Id]", error);
|
||||
return getCurrentCommitId();
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user