refactor: change network mode defaults

This commit is contained in:
Carlos Valente
2025-05-16 20:03:06 +02:00
committed by Carlos Valente
parent 21353b5b00
commit df55b0bf8d
3 changed files with 28 additions and 13 deletions
+15 -1
View File
@@ -83,10 +83,24 @@ export async function requestEventSwap(data: SwapEntry): Promise<AxiosResponse<M
/**
* HTTP request to request application of delay
*/
export async function requestApplyDelay(delayId: string): Promise<AxiosResponse<MessageResponse>> {
export async function requestApplyDelay(delayId: EntryId): Promise<AxiosResponse<MessageResponse>> {
return axios.patch(`${rundownPath}/applydelay/${delayId}`);
}
/**
* HTTP request for dissolving of a block
*/
export async function requestDissolveBlock(blockId: EntryId): Promise<AxiosResponse<MessageResponse>> {
return axios.post(`${rundownPath}/dissolve/${blockId}`);
}
/**
* HTTP request for grouping a list of entries into a block
*/
export async function requestGroupEntries(entryIds: EntryId[]): Promise<AxiosResponse<MessageResponse>> {
return axios.post(`${rundownPath}/group`, { data: { ids: entryIds } });
}
/**
* HTTP request to delete entries
*/
+2 -12
View File
@@ -75,10 +75,7 @@ export const useEntryActions = () => {
const _addEntryMutation = useMutation({
// TODO(v4): optimistic create entry
mutationFn: postAddEntry,
onSettled: () => {
queryClient.invalidateQueries({ queryKey: RUNDOWN });
},
networkMode: 'always',
onSettled: () => queryClient.invalidateQueries({ queryKey: RUNDOWN }),
});
/**
@@ -207,7 +204,6 @@ export const useEntryActions = () => {
onSettled: async () => {
await queryClient.invalidateQueries({ queryKey: RUNDOWN });
},
networkMode: 'always',
});
/**
@@ -372,7 +368,6 @@ export const useEntryActions = () => {
onError: (_error, _newEvent, context) => {
queryClient.setQueryData<Rundown>(RUNDOWN, context?.previousRundown);
},
networkMode: 'always',
});
const batchUpdateEvents = useCallback(
@@ -427,7 +422,6 @@ export const useEntryActions = () => {
onSettled: () => {
queryClient.invalidateQueries({ queryKey: RUNDOWN });
},
networkMode: 'always',
});
/**
@@ -481,7 +475,6 @@ export const useEntryActions = () => {
onSettled: () => {
queryClient.invalidateQueries({ queryKey: RUNDOWN });
},
networkMode: 'always',
});
/**
@@ -505,14 +498,13 @@ export const useEntryActions = () => {
onSettled: () => {
queryClient.invalidateQueries({ queryKey: RUNDOWN });
},
networkMode: 'always',
});
/**
* Applies a given delay
*/
const applyDelay = useCallback(
async (delayEventId: string) => {
async (delayEventId: EntryId) => {
try {
await _applyDelayMutation.mutateAsync(delayEventId);
} catch (error) {
@@ -562,7 +554,6 @@ export const useEntryActions = () => {
onSettled: () => {
queryClient.invalidateQueries({ queryKey: RUNDOWN });
},
networkMode: 'always',
});
/**
@@ -634,7 +625,6 @@ export const useEntryActions = () => {
onSettled: () => {
queryClient.invalidateQueries({ queryKey: RUNDOWN });
},
networkMode: 'always',
});
/**
+11
View File
@@ -1,9 +1,20 @@
import { QueryClient } from '@tanstack/react-query';
import { isOntimeCloud } from '../externals';
export const ontimeQueryClient = new QueryClient({
defaultOptions: {
queries: {
gcTime: 1000 * 60 * 10, // 10 min
},
mutations: {
/**
* React Query detects whether the client is online
* However, web access is not required for the clients when deployed locally
* - use 'always' for clients that may be online
* - use 'online' for clients that are connected to the cloud
*/
networkMode: isOntimeCloud ? 'online' : 'always',
},
},
});