refetching fresh speak videos every second if even one of item is under processing

This commit is contained in:
noumantahir 2023-11-20 17:43:25 +05:00
parent c1cfb81156
commit f00d27575d
2 changed files with 18 additions and 3 deletions

View File

@ -563,8 +563,8 @@
"failed_count":"Failed to upload {failedCount} of {totalCount} selected image(s)",
"publish_manual":"Ready",
"published":"Published",
"encoding_ipfs":"Encoding",
"encoding_preparing":"Preparing",
"encoding_ipfs":"Encoding...",
"encoding_preparing":"Preparing...",
"deleted":"Deleted"
},
"pincode": {

View File

@ -24,10 +24,25 @@ export const useVideoUploadsQuery = () => {
const _fetchVideoUploads = async () => getAllVideoStatuses(currentAccount, pinHash);
// TOOD: filter cache data for post edits to only show already published videos
const _setRefetchInterval = (data:MediaItem[]|undefined) => {
if (data) {
const hasPendingItem = data.find((item) =>
item.speakData?.status === ThreeSpeakStatus.PREPARING ||
item.speakData?.status === ThreeSpeakStatus.ENCODING);
if(hasPendingItem){
return 1000;
}
}
return false;
}
return useQuery<MediaItem[]>([QUERIES.MEDIA.GET_VIDEOS], _fetchVideoUploads, {
initialData: [],
refetchInterval: _setRefetchInterval,
onError: () => {
dispatch(toastNotification(intl.formatMessage({ id: 'alert.fail' })));
},