🪻 distributed transcription service thistle.dunkirk.sh

fix: validate class exists before archiving

Check if class exists when toggling archive status and throw error
if not found. Prevents silent failures when archiving non-existent
classes.

Fixes issue #28 (partial)

dunkirk.sh 8fad605d 07dd273c

verified
Changed files
+5 -1
src
+5 -1
src/lib/classes.ts
···
* Archive or unarchive a class
*/
export function toggleClassArchive(classId: string, archived: boolean): void {
-
db.run("UPDATE classes SET archived = ? WHERE id = ?", [
+
const result = db.run("UPDATE classes SET archived = ? WHERE id = ?", [
archived ? 1 : 0,
classId,
]);
+
+
if (result.changes === 0) {
+
throw new Error("Class not found");
+
}
}
/**