invalidate meeting list on new meeting

This commit is contained in:
Igor Loskutov
2025-09-16 15:41:30 -04:00
parent fb01a89bd3
commit 1087ce5b3a

View File

@@ -75,7 +75,7 @@ export function useTranscriptDelete() {
return $api.useMutation("delete", "/v1/transcripts/{transcript_id}", { return $api.useMutation("delete", "/v1/transcripts/{transcript_id}", {
onSuccess: () => { onSuccess: () => {
queryClient.invalidateQueries({ return queryClient.invalidateQueries({
queryKey: ["get", "/v1/transcripts/search"], queryKey: ["get", "/v1/transcripts/search"],
}); });
}, },
@@ -145,7 +145,7 @@ export function useRoomCreate() {
return $api.useMutation("post", "/v1/rooms", { return $api.useMutation("post", "/v1/rooms", {
onSuccess: () => { onSuccess: () => {
queryClient.invalidateQueries({ return queryClient.invalidateQueries({
queryKey: $api.queryOptions("get", "/v1/rooms").queryKey, queryKey: $api.queryOptions("get", "/v1/rooms").queryKey,
}); });
}, },
@@ -188,7 +188,7 @@ export function useRoomDelete() {
return $api.useMutation("delete", "/v1/rooms/{room_id}", { return $api.useMutation("delete", "/v1/rooms/{room_id}", {
onSuccess: () => { onSuccess: () => {
queryClient.invalidateQueries({ return queryClient.invalidateQueries({
queryKey: $api.queryOptions("get", "/v1/rooms").queryKey, queryKey: $api.queryOptions("get", "/v1/rooms").queryKey,
}); });
}, },
@@ -236,7 +236,7 @@ export function useTranscriptUpdate() {
return $api.useMutation("patch", "/v1/transcripts/{transcript_id}", { return $api.useMutation("patch", "/v1/transcripts/{transcript_id}", {
onSuccess: (data, variables) => { onSuccess: (data, variables) => {
queryClient.invalidateQueries({ return queryClient.invalidateQueries({
queryKey: $api.queryOptions("get", "/v1/transcripts/{transcript_id}", { queryKey: $api.queryOptions("get", "/v1/transcripts/{transcript_id}", {
params: { params: {
path: { transcript_id: variables.params.path.transcript_id }, path: { transcript_id: variables.params.path.transcript_id },
@@ -270,7 +270,7 @@ export function useTranscriptUploadAudio() {
"/v1/transcripts/{transcript_id}/record/upload", "/v1/transcripts/{transcript_id}/record/upload",
{ {
onSuccess: (data, variables) => { onSuccess: (data, variables) => {
queryClient.invalidateQueries({ return queryClient.invalidateQueries({
queryKey: $api.queryOptions( queryKey: $api.queryOptions(
"get", "get",
"/v1/transcripts/{transcript_id}", "/v1/transcripts/{transcript_id}",
@@ -402,7 +402,7 @@ export function useTranscriptParticipantUpdate() {
"/v1/transcripts/{transcript_id}/participants/{participant_id}", "/v1/transcripts/{transcript_id}/participants/{participant_id}",
{ {
onSuccess: (data, variables) => { onSuccess: (data, variables) => {
queryClient.invalidateQueries({ return queryClient.invalidateQueries({
queryKey: $api.queryOptions( queryKey: $api.queryOptions(
"get", "get",
"/v1/transcripts/{transcript_id}/participants", "/v1/transcripts/{transcript_id}/participants",
@@ -430,7 +430,7 @@ export function useTranscriptParticipantCreate() {
"/v1/transcripts/{transcript_id}/participants", "/v1/transcripts/{transcript_id}/participants",
{ {
onSuccess: (data, variables) => { onSuccess: (data, variables) => {
queryClient.invalidateQueries({ return queryClient.invalidateQueries({
queryKey: $api.queryOptions( queryKey: $api.queryOptions(
"get", "get",
"/v1/transcripts/{transcript_id}/participants", "/v1/transcripts/{transcript_id}/participants",
@@ -458,7 +458,7 @@ export function useTranscriptParticipantDelete() {
"/v1/transcripts/{transcript_id}/participants/{participant_id}", "/v1/transcripts/{transcript_id}/participants/{participant_id}",
{ {
onSuccess: (data, variables) => { onSuccess: (data, variables) => {
queryClient.invalidateQueries({ return queryClient.invalidateQueries({
queryKey: $api.queryOptions( queryKey: $api.queryOptions(
"get", "get",
"/v1/transcripts/{transcript_id}/participants", "/v1/transcripts/{transcript_id}/participants",
@@ -486,28 +486,30 @@ export function useTranscriptSpeakerAssign() {
"/v1/transcripts/{transcript_id}/speaker/assign", "/v1/transcripts/{transcript_id}/speaker/assign",
{ {
onSuccess: (data, variables) => { onSuccess: (data, variables) => {
queryClient.invalidateQueries({ return Promise.all([
queryKey: $api.queryOptions( queryClient.invalidateQueries({
"get", queryKey: $api.queryOptions(
"/v1/transcripts/{transcript_id}", "get",
{ "/v1/transcripts/{transcript_id}",
params: { {
path: { transcript_id: variables.params.path.transcript_id }, params: {
path: { transcript_id: variables.params.path.transcript_id },
},
}, },
}, ).queryKey,
).queryKey, }),
}); queryClient.invalidateQueries({
queryClient.invalidateQueries({ queryKey: $api.queryOptions(
queryKey: $api.queryOptions( "get",
"get", "/v1/transcripts/{transcript_id}/participants",
"/v1/transcripts/{transcript_id}/participants", {
{ params: {
params: { path: { transcript_id: variables.params.path.transcript_id },
path: { transcript_id: variables.params.path.transcript_id }, },
}, },
}, ).queryKey,
).queryKey, }),
}); ]);
}, },
onError: (error) => { onError: (error) => {
setError(error as Error, "There was an error assigning the speaker"); setError(error as Error, "There was an error assigning the speaker");
@@ -525,28 +527,30 @@ export function useTranscriptSpeakerMerge() {
"/v1/transcripts/{transcript_id}/speaker/merge", "/v1/transcripts/{transcript_id}/speaker/merge",
{ {
onSuccess: (data, variables) => { onSuccess: (data, variables) => {
queryClient.invalidateQueries({ return Promise.all([
queryKey: $api.queryOptions( queryClient.invalidateQueries({
"get", queryKey: $api.queryOptions(
"/v1/transcripts/{transcript_id}", "get",
{ "/v1/transcripts/{transcript_id}",
params: { {
path: { transcript_id: variables.params.path.transcript_id }, params: {
path: { transcript_id: variables.params.path.transcript_id },
},
}, },
}, ).queryKey,
).queryKey, }),
}); queryClient.invalidateQueries({
queryClient.invalidateQueries({ queryKey: $api.queryOptions(
queryKey: $api.queryOptions( "get",
"get", "/v1/transcripts/{transcript_id}/participants",
"/v1/transcripts/{transcript_id}/participants", {
{ params: {
params: { path: { transcript_id: variables.params.path.transcript_id },
path: { transcript_id: variables.params.path.transcript_id }, },
}, },
}, ).queryKey,
).queryKey, }),
}); ]);
}, },
onError: (error) => { onError: (error) => {
setError(error as Error, "There was an error merging speakers"); setError(error as Error, "There was an error merging speakers");
@@ -574,7 +578,7 @@ export function useMeetingDeactivate() {
setError(error as Error, "Failed to end meeting"); setError(error as Error, "Failed to end meeting");
}, },
onSuccess: () => { onSuccess: () => {
queryClient.invalidateQueries({ return queryClient.invalidateQueries({
predicate: (query) => { predicate: (query) => {
const key = query.queryKey; const key = query.queryKey;
return key.some( return key.some(
@@ -608,7 +612,7 @@ export function useTranscriptCreate() {
return $api.useMutation("post", "/v1/transcripts", { return $api.useMutation("post", "/v1/transcripts", {
onSuccess: () => { onSuccess: () => {
queryClient.invalidateQueries({ return queryClient.invalidateQueries({
queryKey: ["get", "/v1/transcripts/search"], queryKey: ["get", "/v1/transcripts/search"],
}); });
}, },
@@ -623,10 +627,24 @@ export function useRoomsCreateMeeting() {
const queryClient = useQueryClient(); const queryClient = useQueryClient();
return $api.useMutation("post", "/v1/rooms/{room_name}/meeting", { return $api.useMutation("post", "/v1/rooms/{room_name}/meeting", {
onSuccess: () => { onSuccess: async (data, variables) => {
queryClient.invalidateQueries({ const roomName = variables.params.path.room_name;
queryKey: $api.queryOptions("get", "/v1/rooms").queryKey, await Promise.all([
}); queryClient.invalidateQueries({
queryKey: $api.queryOptions("get", "/v1/rooms").queryKey,
}),
queryClient.invalidateQueries({
queryKey: $api.queryOptions(
"get",
"/v1/rooms/{room_name}/meetings/active" satisfies `/v1/rooms/{room_name}/${typeof MEETINGS_ACTIVE_PATH_PARTIAL}`,
{
params: {
path: { room_name: roomName },
},
},
).queryKey,
}),
]);
}, },
onError: (error) => { onError: (error) => {
setError(error as Error, "There was an error creating the meeting"); setError(error as Error, "There was an error creating the meeting");