From 945f3bdceffed7d3bb20ee1849f5f166b3c467bc Mon Sep 17 00:00:00 2001 From: Florian Fischer Date: Fri, 25 Sep 2026 20:19:08 +0200 Subject: utils: introduce course local storage helper class --- src/student-prod.ts | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'src/student-prod.ts') diff --git a/src/student-prod.ts b/src/student-prod.ts index 1addf32..ea258c7 100644 --- a/src/student-prod.ts +++ b/src/student-prod.ts @@ -1,6 +1,11 @@ import type { Graduation } from "./graduation-common.ts"; import { Student } from "./student-common.ts"; -import { getCourseId, getUserIconUrl, getCourseParticipantsUrl } from "./utils-prod.js"; +import { + getCourseId, + CourseLocalStorage, + getUserIconUrl, + getCourseParticipantsUrl, +} from "./utils-prod.js"; import { fetchGraduation } from "./graduation-prod.ts"; declare module "./student-common.ts" { @@ -58,16 +63,18 @@ async function _fetchStudents() { async function fetchStudents(idFilter?: number, nameFilter?: string) { if (students === null) { const studentsPromise = _fetchStudents(); - const storedStudents = localStorage.getItem(`students-${getCourseId()}`); + const storedStudents = CourseLocalStorage.getItem(`students-${getCourseId()}`); if (storedStudents !== null && storedStudents.length > 0) { - studentsPromise.then((fetched) => localStorage.setItem("students", JSON.stringify(fetched))); + studentsPromise.then((fetched) => + CourseLocalStorage.setItem("students", JSON.stringify(fetched)), + ); students = []; for (const o of JSON.parse(storedStudents)) { students.push(new Student(o.id, o.name)); } } else { students = await studentsPromise; - localStorage.setItem("students", JSON.stringify(students)); + CourseLocalStorage.setItem("students", JSON.stringify(students)); } } -- cgit v1.2.3