Skip to content

Commit 503c93a

Browse files
committed
Fix auth.bulkLoad
1 parent cccc07e commit 503c93a

File tree

2 files changed

+15
-10
lines changed

2 files changed

+15
-10
lines changed

src/modules/auth.js

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -745,6 +745,18 @@ export async function loadAdminSettings(courses) {
745745
export async function bulkLoad(fields = [], usr = null, pwd = null, isAdmin = false, isTA = false, ifAccessDenied = () => { }) {
746746
const startTime = Date.now();
747747
await storage.idbReady;
748+
const syncDeleted = async () => {
749+
const cacheIds = {};
750+
const cache = (await storage.idbGet((isAdmin || isTA) ? "adminCache" : "cache")) ||
751+
storage.get((isAdmin || isTA) ? "adminCache" : "cache") || {};
752+
753+
for (const table in cache) {
754+
if (Array.isArray(cache[table] || []))
755+
cacheIds[table] = (cache[table] || []).map(data =>
756+
String(data.id || data.seatCode || data.period || data.key || data.username || 0));
757+
}
758+
return cacheIds;
759+
};
748760
var bulkLoadResponse;
749761
try {
750762
bulkLoadResponse = await fetch(`${domain}/bulk_load${isTA ? '?ta=true' : ''}`, {
@@ -755,14 +767,7 @@ export async function bulkLoad(fields = [], usr = null, pwd = null, isAdmin = fa
755767
pwd,
756768
fields,
757769
lastFetched: storage.get((isAdmin || isTA) ? "lastAdminBulkLoad" : "lastBulkLoad") || null,
758-
syncDeleted: (async () => {
759-
var cacheIds = {};
760-
var cache = (await storage.idbGet((isAdmin || isTA) ? "adminCache" : "cache")) || storage.get((isAdmin || isTA) ? "adminCache" : "cache") || {};
761-
for (const table in cache) {
762-
if (Array.isArray(cache[table] || [])) cacheIds[table] = (cache[table] || []).map(data => String(data.id || data.seatCode || data.period || data.key || data.username || 0));
763-
}
764-
return cacheIds;
765-
})(),
770+
syncDeleted: await syncDeleted(),
766771
}),
767772
});
768773
} catch (e) {

src/modules/ui.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,7 @@ export function view(path = "") {
407407
});
408408
}
409409
const previous = pages.slice(0, pages.length - 1).join("/");
410-
const buttons = ((path === 'api-fail') || (path === 'maintenance-mode')) ? [] : [
410+
const buttons = ((path === 'api-fail') || (path === 'no-course') || (path === 'maintenance-mode')) ? [] : [
411411
{
412412
text: `<i class="bi bi-x-lg"></i>`,
413413
class: "icon",
@@ -427,7 +427,7 @@ export function view(path = "") {
427427
});
428428
}
429429
show(document.querySelector(`[data-modal-page="${pages[0]}"]`), title, buttons);
430-
if (path === "api-fail") startLoader();
430+
if ((path === 'api-fail') || (path === 'no-course') || (path === 'maintenance-mode')) startLoader();
431431
const event = new Event("view");
432432
target.dispatchEvent(event);
433433
}

0 commit comments

Comments
 (0)