mirror of
https://github.com/Monadical-SAS/reflector.git
synced 2025-12-21 04:39:06 +00:00
refactor: clean up api-hooks.ts comments and improve search invalidation
- Remove redundant function category comments (exports are self-explanatory) - Remove obvious inline comments for query invalidation - Fix search endpoint invalidation to clear all queries regardless of parameters
This commit is contained in:
@@ -6,7 +6,6 @@ import { useQueryClient } from "@tanstack/react-query";
|
|||||||
import type { paths } from "../reflector-api";
|
import type { paths } from "../reflector-api";
|
||||||
import useAuthReady from "./useAuthReady";
|
import useAuthReady from "./useAuthReady";
|
||||||
|
|
||||||
// Rooms hooks
|
|
||||||
export function useRoomsList(page: number = 1) {
|
export function useRoomsList(page: number = 1) {
|
||||||
const { setError } = useError();
|
const { setError } = useError();
|
||||||
const { isAuthReady } = useAuthReady();
|
const { isAuthReady } = useAuthReady();
|
||||||
@@ -26,7 +25,6 @@ export function useRoomsList(page: number = 1) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Transcripts hooks
|
|
||||||
export function useTranscriptsSearch(
|
export function useTranscriptsSearch(
|
||||||
q: string = "",
|
q: string = "",
|
||||||
options: {
|
options: {
|
||||||
@@ -66,11 +64,8 @@ export function useTranscriptDelete() {
|
|||||||
|
|
||||||
return $api.useMutation("delete", "/v1/transcripts/{transcript_id}", {
|
return $api.useMutation("delete", "/v1/transcripts/{transcript_id}", {
|
||||||
onSuccess: () => {
|
onSuccess: () => {
|
||||||
// Invalidate transcripts queries to refetch
|
|
||||||
queryClient.invalidateQueries({
|
queryClient.invalidateQueries({
|
||||||
queryKey: $api.queryOptions("get", "/v1/transcripts/search", {
|
queryKey: ["get", "/v1/transcripts/search"],
|
||||||
params: { query: { q: "" } },
|
|
||||||
}).queryKey,
|
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
onError: (error) => {
|
onError: (error) => {
|
||||||
@@ -110,7 +105,6 @@ export function useTranscriptGet(transcriptId: string | null) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Rooms mutations
|
|
||||||
export function useRoomCreate() {
|
export function useRoomCreate() {
|
||||||
const { setError } = useError();
|
const { setError } = useError();
|
||||||
const queryClient = useQueryClient();
|
const queryClient = useQueryClient();
|
||||||
@@ -159,7 +153,7 @@ export function useRoomDelete() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Zulip hooks - NOTE: These endpoints are not in the OpenAPI spec yet
|
// NOTE: Zulip endpoints are not in the OpenAPI spec yet
|
||||||
export function useZulipStreams() {
|
export function useZulipStreams() {
|
||||||
const { setError } = useError();
|
const { setError } = useError();
|
||||||
const { isAuthReady } = useAuthReady();
|
const { isAuthReady } = useAuthReady();
|
||||||
@@ -192,14 +186,12 @@ export function useZulipTopics(streamId: number | null) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Transcript mutations
|
|
||||||
export function useTranscriptUpdate() {
|
export function useTranscriptUpdate() {
|
||||||
const { setError } = useError();
|
const { setError } = useError();
|
||||||
const queryClient = useQueryClient();
|
const queryClient = useQueryClient();
|
||||||
|
|
||||||
return $api.useMutation("patch", "/v1/transcripts/{transcript_id}", {
|
return $api.useMutation("patch", "/v1/transcripts/{transcript_id}", {
|
||||||
onSuccess: (data, variables) => {
|
onSuccess: (data, variables) => {
|
||||||
// Invalidate and refetch transcript data
|
|
||||||
queryClient.invalidateQueries({
|
queryClient.invalidateQueries({
|
||||||
queryKey: $api.queryOptions("get", "/v1/transcripts/{transcript_id}", {
|
queryKey: $api.queryOptions("get", "/v1/transcripts/{transcript_id}", {
|
||||||
params: {
|
params: {
|
||||||
@@ -238,7 +230,6 @@ export function useTranscriptUploadAudio() {
|
|||||||
"/v1/transcripts/{transcript_id}/record/upload",
|
"/v1/transcripts/{transcript_id}/record/upload",
|
||||||
{
|
{
|
||||||
onSuccess: (data, variables) => {
|
onSuccess: (data, variables) => {
|
||||||
// Invalidate transcript to refresh status
|
|
||||||
queryClient.invalidateQueries({
|
queryClient.invalidateQueries({
|
||||||
queryKey: $api.queryOptions(
|
queryKey: $api.queryOptions(
|
||||||
"get",
|
"get",
|
||||||
@@ -258,7 +249,6 @@ export function useTranscriptUploadAudio() {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Transcript queries
|
|
||||||
export function useTranscriptWaveform(transcriptId: string | null) {
|
export function useTranscriptWaveform(transcriptId: string | null) {
|
||||||
const { setError } = useError();
|
const { setError } = useError();
|
||||||
const { isAuthReady } = useAuthReady();
|
const { isAuthReady } = useAuthReady();
|
||||||
@@ -355,7 +345,6 @@ export function useTranscriptTopicsWithWordsPerSpeaker(
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Participant operations
|
|
||||||
export function useTranscriptParticipants(transcriptId: string | null) {
|
export function useTranscriptParticipants(transcriptId: string | null) {
|
||||||
const { setError } = useError();
|
const { setError } = useError();
|
||||||
const { isAuthReady } = useAuthReady();
|
const { isAuthReady } = useAuthReady();
|
||||||
@@ -383,7 +372,6 @@ export function useTranscriptParticipantUpdate() {
|
|||||||
"/v1/transcripts/{transcript_id}/participants/{participant_id}",
|
"/v1/transcripts/{transcript_id}/participants/{participant_id}",
|
||||||
{
|
{
|
||||||
onSuccess: (data, variables) => {
|
onSuccess: (data, variables) => {
|
||||||
// Invalidate participants list
|
|
||||||
queryClient.invalidateQueries({
|
queryClient.invalidateQueries({
|
||||||
queryKey: $api.queryOptions(
|
queryKey: $api.queryOptions(
|
||||||
"get",
|
"get",
|
||||||
@@ -412,7 +400,6 @@ export function useTranscriptParticipantCreate() {
|
|||||||
"/v1/transcripts/{transcript_id}/participants",
|
"/v1/transcripts/{transcript_id}/participants",
|
||||||
{
|
{
|
||||||
onSuccess: (data, variables) => {
|
onSuccess: (data, variables) => {
|
||||||
// Invalidate participants list
|
|
||||||
queryClient.invalidateQueries({
|
queryClient.invalidateQueries({
|
||||||
queryKey: $api.queryOptions(
|
queryKey: $api.queryOptions(
|
||||||
"get",
|
"get",
|
||||||
@@ -441,7 +428,6 @@ export function useTranscriptParticipantDelete() {
|
|||||||
"/v1/transcripts/{transcript_id}/participants/{participant_id}",
|
"/v1/transcripts/{transcript_id}/participants/{participant_id}",
|
||||||
{
|
{
|
||||||
onSuccess: (data, variables) => {
|
onSuccess: (data, variables) => {
|
||||||
// Invalidate participants list
|
|
||||||
queryClient.invalidateQueries({
|
queryClient.invalidateQueries({
|
||||||
queryKey: $api.queryOptions(
|
queryKey: $api.queryOptions(
|
||||||
"get",
|
"get",
|
||||||
@@ -470,7 +456,6 @@ export function useTranscriptSpeakerAssign() {
|
|||||||
"/v1/transcripts/{transcript_id}/speaker/assign",
|
"/v1/transcripts/{transcript_id}/speaker/assign",
|
||||||
{
|
{
|
||||||
onSuccess: (data, variables) => {
|
onSuccess: (data, variables) => {
|
||||||
// Invalidate transcript and participants
|
|
||||||
queryClient.invalidateQueries({
|
queryClient.invalidateQueries({
|
||||||
queryKey: $api.queryOptions(
|
queryKey: $api.queryOptions(
|
||||||
"get",
|
"get",
|
||||||
@@ -510,7 +495,6 @@ export function useTranscriptSpeakerMerge() {
|
|||||||
"/v1/transcripts/{transcript_id}/speaker/merge",
|
"/v1/transcripts/{transcript_id}/speaker/merge",
|
||||||
{
|
{
|
||||||
onSuccess: (data, variables) => {
|
onSuccess: (data, variables) => {
|
||||||
// Invalidate transcript and participants
|
|
||||||
queryClient.invalidateQueries({
|
queryClient.invalidateQueries({
|
||||||
queryKey: $api.queryOptions(
|
queryKey: $api.queryOptions(
|
||||||
"get",
|
"get",
|
||||||
@@ -541,7 +525,6 @@ export function useTranscriptSpeakerMerge() {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Meeting operations
|
|
||||||
export function useMeetingAudioConsent() {
|
export function useMeetingAudioConsent() {
|
||||||
const { setError } = useError();
|
const { setError } = useError();
|
||||||
|
|
||||||
@@ -552,7 +535,6 @@ export function useMeetingAudioConsent() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// WebRTC operations
|
|
||||||
export function useTranscriptWebRTC() {
|
export function useTranscriptWebRTC() {
|
||||||
const { setError } = useError();
|
const { setError } = useError();
|
||||||
|
|
||||||
@@ -567,18 +549,14 @@ export function useTranscriptWebRTC() {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Transcript creation
|
|
||||||
export function useTranscriptCreate() {
|
export function useTranscriptCreate() {
|
||||||
const { setError } = useError();
|
const { setError } = useError();
|
||||||
const queryClient = useQueryClient();
|
const queryClient = useQueryClient();
|
||||||
|
|
||||||
return $api.useMutation("post", "/v1/transcripts", {
|
return $api.useMutation("post", "/v1/transcripts", {
|
||||||
onSuccess: () => {
|
onSuccess: () => {
|
||||||
// Invalidate transcripts list
|
|
||||||
queryClient.invalidateQueries({
|
queryClient.invalidateQueries({
|
||||||
queryKey: $api.queryOptions("get", "/v1/transcripts/search", {
|
queryKey: ["get", "/v1/transcripts/search"],
|
||||||
params: { query: { q: "" } },
|
|
||||||
}).queryKey,
|
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
onError: (error) => {
|
onError: (error) => {
|
||||||
@@ -587,14 +565,12 @@ export function useTranscriptCreate() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Rooms meeting operations
|
|
||||||
export function useRoomsCreateMeeting() {
|
export function useRoomsCreateMeeting() {
|
||||||
const { setError } = useError();
|
const { setError } = useError();
|
||||||
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: () => {
|
||||||
// Invalidate rooms list to refresh meeting data
|
|
||||||
queryClient.invalidateQueries({
|
queryClient.invalidateQueries({
|
||||||
queryKey: $api.queryOptions("get", "/v1/rooms").queryKey,
|
queryKey: $api.queryOptions("get", "/v1/rooms").queryKey,
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user