Skip to content

Commit

Permalink
[debug] disappearing saved timetables
Browse files Browse the repository at this point in the history
  • Loading branch information
cupoftea4 committed Oct 27, 2024
1 parent 8f850cf commit 46bd8c8
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/utils/data/TimetableManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const GROUPS = "groups";
const LECTURERS = "lecturers";
const DEPARTMENTS = "departments";
const SELECTIVE_GROUPS = "selective_groups";
const TIMETABLES = "cached_timetables";
const SAVED_TIMETABLES = "cached_timetables";
const EXAMS_TIMETABLES = "cached_exams_timetables";
const TIMETABLE = "timetable_";
const PARTIAL_GROUPS_1 = "partial_groups_1";
Expand Down Expand Up @@ -56,7 +56,7 @@ class TimetableManager {

async init() {
// cache only data
this.timetables = (await storage.getItem(TIMETABLES)) ?? [];
this.timetables = (await storage.getItem(SAVED_TIMETABLES)) ?? [];
this.mergedTimetable = (await storage.getItem(MERGED_TIMETABLE)) ?? null;
storage.getItem<CachedTimetable[]>(EXAMS_TIMETABLES).then((data) => {
this.examsTimetables = data ?? [];
Expand Down Expand Up @@ -245,8 +245,8 @@ class TimetableManager {
subgroup,
});
storage.setItem(TIMETABLE + group, timetable);
storage.setItem(TIMETABLES, this.timetables);
localStorage.setItem(TIMETABLES, JSON.stringify(this.timetables));
storage.setItem(SAVED_TIMETABLES, this.timetables);
localStorage.setItem(SAVED_TIMETABLES, JSON.stringify(this.timetables));
return timetable;
}

Expand Down Expand Up @@ -310,7 +310,8 @@ class TimetableManager {
time: data.time,
subgroup,
});
return storage.setItem(TIMETABLES, this.timetables);
localStorage.setItem(SAVED_TIMETABLES, JSON.stringify(this.timetables));
return storage.setItem(SAVED_TIMETABLES, this.timetables);
}

getSubgroup(groupName?: string) {
Expand Down Expand Up @@ -338,7 +339,8 @@ class TimetableManager {
const groupNameClean = groupName.trim();
this.timetables = this.timetables.filter((el) => el.group !== groupNameClean);
storage.deleteItem(TIMETABLE + groupNameClean);
return storage.setItem(TIMETABLES, this.timetables);
localStorage.setItem(SAVED_TIMETABLES, JSON.stringify(this.timetables));
return storage.setItem(SAVED_TIMETABLES, this.timetables);
}

saveMergedTimetable(timetablesToMerge: string[]) {
Expand Down

0 comments on commit 46bd8c8

Please sign in to comment.