✨ Add basic handling for local timetables
This commit is contained in:
15
src/store.js
15
src/store.js
@ -14,6 +14,9 @@ export const timetableId = ref(localStorage.getItem("timetableId") || "none");
|
||||
export const timetableGroups = ref(
|
||||
JSON.parse(localStorage.getItem("timetableGroups") || "[]")
|
||||
);
|
||||
export const localTimetables = ref(
|
||||
JSON.parse(localStorage.getItem("timetables")) || []
|
||||
);
|
||||
|
||||
export const theme = ref(localStorage.getItem("theme") || "auto");
|
||||
|
||||
@ -31,6 +34,9 @@ watch(
|
||||
},
|
||||
{ deep: true }
|
||||
);
|
||||
watch(localTimetables, (newValue) => {
|
||||
localStorage.setItem("timetables", JSON.stringify(newValue));
|
||||
});
|
||||
watch(theme, (newValue) => {
|
||||
localStorage.setItem("theme", newValue);
|
||||
});
|
||||
@ -52,10 +58,15 @@ export const changeDate = ref(new Date());
|
||||
|
||||
/* Data store */
|
||||
export const timetable = computed(() => {
|
||||
const selectedTimetable = timetables.value.find(
|
||||
const localTimetable = localTimetables.value.find(
|
||||
(e) => e.id == timetableId.value
|
||||
);
|
||||
return selectedTimetable || { trusted: true, source: "", data: [] };
|
||||
const remoteTimetable = timetables.value.find(
|
||||
(e) => e.id == timetableId.value
|
||||
);
|
||||
return (
|
||||
localTimetable || remoteTimetable || { trusted: true, source: "", data: [] }
|
||||
);
|
||||
});
|
||||
export const timetables = ref([]);
|
||||
export const times = ref([]);
|
||||
|
Reference in New Issue
Block a user