Merge branch 'dev' into feat/class-functionality
This commit is contained in:
commit
4dd053edfb
8 changed files with 172 additions and 62 deletions
|
@ -19,32 +19,51 @@ import type { TeacherInvitationsResponse } from "@/controllers/teacher-invitatio
|
|||
const classController = new ClassController();
|
||||
|
||||
/* Query cache keys */
|
||||
function classesQueryKey(full: boolean) {
|
||||
type ClassesQueryKey = ["classes", boolean];
|
||||
|
||||
function classesQueryKey(full: boolean): ClassesQueryKey {
|
||||
return ["classes", full];
|
||||
}
|
||||
function classQueryKey(classid: string) {
|
||||
|
||||
type ClassQueryKey = ["class", string];
|
||||
|
||||
function classQueryKey(classid: string): ClassQueryKey {
|
||||
return ["class", classid];
|
||||
}
|
||||
function classStudentsKey(classid: string, full: boolean) {
|
||||
|
||||
type ClassStudentsKey = ["class-students", string, boolean];
|
||||
|
||||
function classStudentsKey(classid: string, full: boolean): ClassStudentsKey {
|
||||
return ["class-students", classid, full];
|
||||
}
|
||||
function classTeachersKey(classid: string, full: boolean) {
|
||||
|
||||
type ClassTeachersKey = ["class-teachers", string, boolean];
|
||||
|
||||
function classTeachersKey(classid: string, full: boolean): ClassTeachersKey {
|
||||
return ["class-teachers", classid, full];
|
||||
}
|
||||
function classTeacherInvitationsKey(classid: string, full: boolean) {
|
||||
|
||||
type ClassTeacherInvitationsKey = ["class-teacher-invitations", string, boolean];
|
||||
|
||||
function classTeacherInvitationsKey(classid: string, full: boolean): ClassTeacherInvitationsKey {
|
||||
return ["class-teacher-invitations", classid, full];
|
||||
}
|
||||
function classAssignmentsKey(classid: string, full: boolean) {
|
||||
|
||||
type ClassAssignmentsKey = ["class-assignments", string, boolean];
|
||||
|
||||
function classAssignmentsKey(classid: string, full: boolean): ClassAssignmentsKey {
|
||||
return ["class-assignments", classid, full];
|
||||
}
|
||||
|
||||
export async function invalidateAllClassKeys(queryClient: QueryClient, classid?: string) {
|
||||
export async function invalidateAllClassKeys(queryClient: QueryClient, classid?: string): Promise<void> {
|
||||
const keys = ["class", "class-students", "class-teachers", "class-teacher-invitations", "class-assignments"];
|
||||
|
||||
for (const key of keys) {
|
||||
const queryKey = [key, classid].filter((arg) => arg !== undefined);
|
||||
await queryClient.invalidateQueries({ queryKey: queryKey });
|
||||
}
|
||||
await Promise.all(
|
||||
keys.map(async (key) => {
|
||||
const queryKey = [key, classid].filter((arg) => arg !== undefined);
|
||||
return queryClient.invalidateQueries({ queryKey: queryKey });
|
||||
}),
|
||||
);
|
||||
|
||||
await queryClient.invalidateQueries({ queryKey: ["classes"] });
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue