Skip to content

Commit

Permalink
feat: declare uphf features in services switch
Browse files Browse the repository at this point in the history
  • Loading branch information
tom-theret committed Oct 7, 2024
1 parent c9861c0 commit e1d28f3
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/services/news.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import type { Information } from "./shared/Information";
import { checkIfSkoSupported } from "./skolengo/default-personalization";
import { error } from "@/utils/logger/logger";
import { newsRead } from "pawnote";
import { ca } from "date-fns/locale";

/**
* Updates the state and cache for the news.
Expand All @@ -30,6 +31,12 @@ export async function updateNewsInCache <T extends Account> (account: T): Promis
useNewsStore.getState().updateInformations(informations);
break;
}
case AccountService.UPHF: {
const { getNews } = await import("./uphf/data/news");
const informations = await getNews(account);
useNewsStore.getState().updateInformations(informations);
break;
}
default: {
throw new Error("Service not implemented.");
}
Expand All @@ -48,6 +55,9 @@ export async function setNewsRead <T extends Account> (account: T, message: Info
case AccountService.Local: {
break;
}
case AccountService.UPHF: {
break;
}
default: {
throw new Error("Service not implemented.");
}
Expand Down
4 changes: 4 additions & 0 deletions src/services/reload-account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ export async function reload <T extends Account> (account: T): Promise<Reconnect
const res = await reload(account);
return { instance: res.instance, authentication: res.authentication };
}
case AccountService.UPHF: {
const { reloadInstance } = await import("./uphf/reload-uphf");
return await reloadInstance(account.authentication) as Reconnected<T>;
}
default: {
throw new Error("Service not implemented.");
}
Expand Down
6 changes: 6 additions & 0 deletions src/services/timetable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ export async function updateTimetableForWeekInCache <T extends Account> (account
useTimetableStore.getState().updateClasses(epochWeekNumber, timetable);
break;
}
case AccountService.UPHF: {
const { getTimetableForWeek } = await import("./uphf/data/timetable");
const timetable = await getTimetableForWeek(account, epochWeekNumber);
useTimetableStore.getState().updateClasses(epochWeekNumber, timetable);
break;
}
default: {
throw new Error("Service not implemented.");
}
Expand Down

0 comments on commit e1d28f3

Please sign in to comment.