mirror of
https://github.com/fankes/beszel.git
synced 2025-10-20 02:09:28 +08:00
fix: prevent multiple concurrent fetches in updateSystemList function
fix: correctly reset isFetchingSystems flag in updateSystemList function
This commit is contained in:
committed by
Henry Dollman
parent
58085bf300
commit
5b478c11eb
@@ -42,23 +42,34 @@ const verifyAuth = () => {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let isFetchingSystems = false;
|
||||||
|
|
||||||
export const updateSystemList = async () => {
|
export const updateSystemList = async () => {
|
||||||
try {
|
|
||||||
const records = await pb
|
if (isFetchingSystems) return;
|
||||||
.collection<SystemRecord>("systems")
|
isFetchingSystems = true
|
||||||
.getFullList({ sort: "+name", fields: "id,name,host,info,status" })
|
|
||||||
if (records.length) {
|
try {
|
||||||
$systems.set(records)
|
const records = await pb
|
||||||
} else {
|
.collection<SystemRecord>("systems")
|
||||||
verifyAuth()
|
.getFullList({ sort: "+name", fields: "id,name,host,info,status" });
|
||||||
}
|
|
||||||
} catch (err) {
|
if (records.length) {
|
||||||
// @ts-ignore supress pocketbase auto cancellation error
|
$systems.set(records);
|
||||||
if (err.isAbort) {
|
} else {
|
||||||
return
|
verifyAuth();
|
||||||
}
|
}
|
||||||
|
} catch (e: any) {
|
||||||
|
// Suppressing pocketbase auto-cancellation error
|
||||||
|
|
||||||
|
if (e.isAbort || e.status === 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
isFetchingSystems = false
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
|
|
||||||
export const updateAlerts = () => {
|
export const updateAlerts = () => {
|
||||||
pb.collection("alerts")
|
pb.collection("alerts")
|
||||||
|
Reference in New Issue
Block a user