Skip to content

Commit 41b425e

Browse files
committed
Separate student last bulk load from admin/TA last bulk load
1 parent c664ecd commit 41b425e

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

src/modules/auth.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -213,16 +213,16 @@ export async function sync(hideWelcome = true, returnFunction = null) {
213213
if (r.notifications.length > 0) ui.toast(`You have ${r.notifications.length} unread notification${(r.notifications.length === 1) ? '' : 's'}.`, 5000, 'info', 'bi bi-bell-fill');
214214
const combinedSettings = sortKeys({
215215
...Object.fromEntries(
216-
Object.entries(storage.all()).filter(([key]) => key !== "password" && key !== "code" && key !== "usr" && key !== "pwd" && key !== "history" && key !== "questionsAnswered" && key !== "developer" && key !== "cache" && key !== "lastBulkLoad" && key !== "adminCache")
216+
Object.entries(storage.all()).filter(([key]) => key !== "password" && key !== "code" && key !== "usr" && key !== "pwd" && key !== "history" && key !== "questionsAnswered" && key !== "developer" && key !== "cache" && key !== "lastBulkLoad" && key !== "adminCache" && key !== "lastAdminBulkLoad")
217217
),
218218
...Object.fromEntries(
219-
Object.entries(r.settings).filter(([key]) => key !== "password" && key !== "code" && key !== "usr" && key !== "pwd" && key !== "history" && key !== "questionsAnswered" && key !== "developer" && key !== "cache" && key !== "lastBulkLoad" && key !== "adminCache")
219+
Object.entries(r.settings).filter(([key]) => key !== "password" && key !== "code" && key !== "usr" && key !== "pwd" && key !== "history" && key !== "questionsAnswered" && key !== "developer" && key !== "cache" && key !== "lastBulkLoad" && key !== "adminCache" && key !== "lastAdminBulkLoad")
220220
),
221221
});
222222
var settingsIsSynced = JSON.stringify(sortKeys(Object.fromEntries(
223-
Object.entries(r.settings).filter(([key]) => key !== "password" && key !== "code" && key !== "usr" && key !== "pwd" && key !== "history" && key !== "questionsAnswered" && key !== "developer" && key !== "cache" && key !== "lastBulkLoad" && key !== "adminCache")
223+
Object.entries(r.settings).filter(([key]) => key !== "password" && key !== "code" && key !== "usr" && key !== "pwd" && key !== "history" && key !== "questionsAnswered" && key !== "developer" && key !== "cache" && key !== "lastBulkLoad" && key !== "adminCache" && key !== "lastAdminBulkLoad")
224224
))) === JSON.stringify(sortKeys(Object.fromEntries(
225-
Object.entries(storage.all()).filter(([key]) => key !== "password" && key !== "code" && key !== "usr" && key !== "pwd" && key !== "history" && key !== "questionsAnswered" && key !== "developer" && key !== "cache" && key !== "lastBulkLoad" && key !== "adminCache")
225+
Object.entries(storage.all()).filter(([key]) => key !== "password" && key !== "code" && key !== "usr" && key !== "pwd" && key !== "history" && key !== "questionsAnswered" && key !== "developer" && key !== "cache" && key !== "lastBulkLoad" && key !== "adminCache" && key !== "lastAdminBulkLoad")
226226
)));
227227
console.log(`${settingsIsSynced ? '🟢' : '🟡'} Settings is ${!settingsIsSynced ? 'not ' : ''}synced!`);
228228
if (settingsIsSynced) {
@@ -261,7 +261,7 @@ export async function sync(hideWelcome = true, returnFunction = null) {
261261
.then(async () => {
262262
if (r.settings && Object.keys(r.settings).length > 0) {
263263
Object.entries(r.settings).forEach(([key, value]) => {
264-
if (key !== "password" && key !== "code" && key !== "usr" && key !== "pwd" && key !== "history" && key !== "questionsAnswered" && key !== "developer" && key !== "cache" && key !== "lastBulkLoad" && key !== "adminCache") storage.set(key, value);
264+
if (key !== "password" && key !== "code" && key !== "usr" && key !== "pwd" && key !== "history" && key !== "questionsAnswered" && key !== "developer" && key !== "cache" && key !== "lastBulkLoad" && key !== "adminCache" && key !== "lastAdminBulkLoad") storage.set(key, value);
265265
});
266266
await themes.syncTheme();
267267
if (document.getElementById('checker')) document.getElementById('checker').classList = r.settings['layout'] || '';
@@ -535,7 +535,7 @@ export async function syncManual(hideWelcome = false) {
535535
body: JSON.stringify({
536536
"seatCode": storage.get("code"),
537537
"password": password,
538-
"settings": Object.fromEntries(Object.entries(storage.all()).filter(([key]) => key !== "password" && key !== "code" && key !== "usr" && key !== "pwd" && key !== "history" && key !== "questionsAnswered" && key !== "developer" && key !== "cache" && key !== "lastBulkLoad" && key !== "adminCache")),
538+
"settings": Object.fromEntries(Object.entries(storage.all()).filter(([key]) => key !== "password" && key !== "code" && key !== "usr" && key !== "pwd" && key !== "history" && key !== "questionsAnswered" && key !== "developer" && key !== "cache" && key !== "lastBulkLoad" && key !== "adminCache" && key !== "lastAdminBulkLoad")),
539539
})
540540
})
541541
.then(async (r) => {
@@ -582,7 +582,7 @@ export async function syncManual(hideWelcome = false) {
582582
prompt(false, () => {
583583
if (r.settings && Object.keys(r.settings).length > 0) {
584584
Object.entries(r.settings).forEach(([key, value]) => {
585-
if (key !== "password" && key !== "code" && key !== "usr" && key !== "pwd" && key !== "history" && key !== "questionsAnswered" && key !== "developer" && key !== "cache" && key !== "lastBulkLoad" && key !== "adminCache") storage.set(key, value);
585+
if (key !== "password" && key !== "code" && key !== "usr" && key !== "pwd" && key !== "history" && key !== "questionsAnswered" && key !== "developer" && key !== "cache" && key !== "lastBulkLoad" && key !== "adminCache" && key !== "lastAdminBulkLoad") storage.set(key, value);
586586
});
587587
ui.toast("Settings restored successfully!", 3000, "success", "bi bi-check-circle-fill");
588588
window.location.reload();
@@ -749,7 +749,7 @@ export async function bulkLoad(fields = [], usr = null, pwd = null, isAdmin = fa
749749
usr,
750750
pwd,
751751
fields,
752-
lastFetched: storage.get("lastBulkLoad") || null,
752+
lastFetched: storage.get(isAdmin ? "lastAdminBulkLoad" : "lastBulkLoad") || null,
753753
syncDeleted: (() => {
754754
var cacheIds = {};
755755
var cache = storage.get(isAdmin ? "adminCache" : "cache") || {};
@@ -764,7 +764,7 @@ export async function bulkLoad(fields = [], usr = null, pwd = null, isAdmin = fa
764764
var updatedBulkLoad = {};
765765
for (const table in fetchedBulkLoad) {
766766
if (table === 'asOf' || table === 'syncDeleted') continue;
767-
if (storage.get("lastBulkLoad") || null) {
767+
if (storage.get(isAdmin ? "lastAdminBulkLoad" : "lastBulkLoad") || null) {
768768
var deletedData;
769769
var existingData;
770770
var mergedData;
@@ -787,7 +787,7 @@ export async function bulkLoad(fields = [], usr = null, pwd = null, isAdmin = fa
787787
updatedBulkLoad[table] = fetchedBulkLoad[table];
788788
}
789789
}
790-
storage.set("lastBulkLoad", fetchedBulkLoad.asOf || null);
790+
storage.set(isAdmin ? "lastAdminBulkLoad" : "lastBulkLoad", fetchedBulkLoad.asOf || null);
791791
storage.set(isAdmin ? "adminCache" : "cache", updatedBulkLoad || fetchedBulkLoad || {});
792792
const loadTime = ((Date.now() - startTime) / 1000).toFixed(2);
793793
console.log(`${(loadTime < 1) ? '🟢' : ((loadTime > 5) ? '🔴' : '🟡')} Bulk load fetched in ${loadTime}s`);

0 commit comments

Comments
 (0)