|
1 |
| -import { useMutation, useQuery } from 'react-query'; |
2 |
| -import { getCachingStatus, updateCaching } from '@/api/caching'; |
3 |
| -import { notifySuccess } from '@/utils/notification'; |
4 |
| -import { useStreamStore, streamStoreReducers } from '@/pages/Stream/providers/StreamProvider'; |
| 1 | +// import { useMutation, useQuery } from 'react-query'; |
| 2 | +// import { getCachingStatus, updateCaching } from '@/api/caching'; |
| 3 | +// import { notifySuccess } from '@/utils/notification'; |
| 4 | +// import { useStreamStore, streamStoreReducers } from '@/pages/Stream/providers/StreamProvider'; |
5 | 5 |
|
6 |
| -const { setCacheEnabled } = streamStoreReducers; |
| 6 | +// const { setCacheEnabled } = streamStoreReducers; |
7 | 7 |
|
8 |
| -export const useCacheToggle = (streamName: string) => { |
9 |
| - const [, setStreamStore] = useStreamStore(() => null); |
10 |
| - const { |
11 |
| - data: checkCacheData, |
12 |
| - refetch: getCacheStatusRefetch, |
13 |
| - isError: getCacheError, |
14 |
| - isLoading: getCacheLoading, |
15 |
| - } = useQuery(['fetch-cache-status', streamName], () => getCachingStatus(streamName), { |
16 |
| - retry: false, |
17 |
| - enabled: streamName !== '', |
18 |
| - refetchOnWindowFocus: false, |
19 |
| - onSuccess: (data) => { |
20 |
| - setStreamStore((store) => setCacheEnabled(store, data.data)); |
21 |
| - }, |
22 |
| - }); |
| 8 | +// export const useCacheToggle = (streamName: string) => { |
| 9 | +// const [, setStreamStore] = useStreamStore(() => null); |
| 10 | +// const { |
| 11 | +// data: checkCacheData, |
| 12 | +// refetch: getCacheStatusRefetch, |
| 13 | +// isError: getCacheError, |
| 14 | +// isLoading: getCacheLoading, |
| 15 | +// } = useQuery(['fetch-cache-status', streamName], () => getCachingStatus(streamName), { |
| 16 | +// retry: false, |
| 17 | +// enabled: streamName !== '', |
| 18 | +// refetchOnWindowFocus: false, |
| 19 | +// onSuccess: (data) => { |
| 20 | +// setStreamStore((store) => setCacheEnabled(store, data.data)); |
| 21 | +// }, |
| 22 | +// }); |
23 | 23 |
|
24 |
| - const { mutate: updateCacheStatus } = useMutation( |
25 |
| - ({ type }: { type: boolean; onSuccess?: () => void }) => updateCaching(streamName, type), |
26 |
| - { |
27 |
| - onSuccess: (_data, variables) => { |
28 |
| - notifySuccess({ message: `Cache status modified successfully` }); |
29 |
| - getCacheStatusRefetch(); |
30 |
| - variables.onSuccess && variables.onSuccess(); |
31 |
| - }, |
32 |
| - }, |
33 |
| - ); |
| 24 | +// const { mutate: updateCacheStatus } = useMutation( |
| 25 | +// ({ type }: { type: boolean; onSuccess?: () => void }) => updateCaching(streamName, type), |
| 26 | +// { |
| 27 | +// onSuccess: (_data, variables) => { |
| 28 | +// notifySuccess({ message: `Cache status modified successfully` }); |
| 29 | +// getCacheStatusRefetch(); |
| 30 | +// variables.onSuccess && variables.onSuccess(); |
| 31 | +// }, |
| 32 | +// }, |
| 33 | +// ); |
34 | 34 |
|
35 |
| - return { |
36 |
| - isCacheEnabled: checkCacheData?.data, |
37 |
| - getCacheError, |
38 |
| - updateCacheStatus, |
39 |
| - getCacheLoading, |
40 |
| - }; |
41 |
| -}; |
| 35 | +// return { |
| 36 | +// isCacheEnabled: checkCacheData?.data, |
| 37 | +// getCacheError, |
| 38 | +// updateCacheStatus, |
| 39 | +// getCacheLoading, |
| 40 | +// }; |
| 41 | +// }; |
0 commit comments