loads of polish and bug fixes

This commit is contained in:
Chris Sanden
2026-05-05 15:41:44 +02:00
parent a4f99a50d0
commit 2bb2ac63a0
8 changed files with 379 additions and 53 deletions

View File

@@ -3,15 +3,24 @@ import type { SessionType } from '@/lib/types';
const notificationKey = (aId: string) => `assignment_notification_${aId}`;
const activeSprintKey = 'active_sprint';
const studyCycleKey = 'study_cycle';
export type ActiveSession = {
sessionId: string;
sessionType: SessionType;
taskId: string | null;
returnTaskId?: string | null;
durationSeconds: number;
endTime: number;
};
export type StudyCycle = {
taskId: string;
completedFocusSessions: number;
lastCompletedSessionType: SessionType;
lastCompletedAt: number;
};
export async function SaveAssignmentNotificationId(aId: string, notificationId: string) {
await AsyncStorage.setItem(notificationKey(aId), notificationId);
}
@@ -41,3 +50,21 @@ export async function GetActiveSession() {
export async function RemoveActiveSession() {
await AsyncStorage.removeItem(activeSprintKey);
}
export async function SaveStudyCycle(studyCycle: StudyCycle) {
await AsyncStorage.setItem(studyCycleKey, JSON.stringify(studyCycle));
}
export async function GetStudyCycle() {
const studyCycle = await AsyncStorage.getItem(studyCycleKey);
if (!studyCycle) {
return null;
}
return JSON.parse(studyCycle) as StudyCycle;
}
export async function RemoveStudyCycle() {
await AsyncStorage.removeItem(studyCycleKey);
}