mirror of
https://github.com/fankes/beszel.git
synced 2025-10-20 02:09:28 +08:00
refactor: updateSystemList function
This commit is contained in:
@@ -42,33 +42,28 @@ const verifyAuth = () => {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
let isFetchingSystems = false;
|
export const updateSystemList = (() => {
|
||||||
|
let isFetchingSystems = false
|
||||||
|
return async () => {
|
||||||
|
if (isFetchingSystems) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
isFetchingSystems = true
|
||||||
|
try {
|
||||||
|
const records = await pb
|
||||||
|
.collection<SystemRecord>("systems")
|
||||||
|
.getFullList({ sort: "+name", fields: "id,name,host,info,status" })
|
||||||
|
|
||||||
export const updateSystemList = async () => {
|
if (records.length) {
|
||||||
|
$systems.set(records)
|
||||||
if (isFetchingSystems) return;
|
} else {
|
||||||
isFetchingSystems = true
|
verifyAuth()
|
||||||
|
}
|
||||||
try {
|
} finally {
|
||||||
const records = await pb
|
isFetchingSystems = false
|
||||||
.collection<SystemRecord>("systems")
|
}
|
||||||
.getFullList({ sort: "+name", fields: "id,name,host,info,status" });
|
|
||||||
|
|
||||||
if (records.length) {
|
|
||||||
$systems.set(records);
|
|
||||||
} else {
|
|
||||||
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 = () => {
|
||||||
|
Reference in New Issue
Block a user