fix progress

This commit is contained in:
PhilReact 2025-06-21 15:20:12 +03:00
parent a18f9de6d6
commit aedd49a07d
3 changed files with 20 additions and 9 deletions

View File

@ -173,6 +173,9 @@ export const MultiPublishDialogComponent = () => {
maxWidth="sm" maxWidth="sm"
sx={{ zIndex: 999990 }} sx={{ zIndex: 999990 }}
slotProps={{ paper: { elevation: 0 } }} slotProps={{ paper: { elevation: 0 } }}
disableEnforceFocus
disableAutoFocus
disableRestoreFocus
> >
<DialogTitle>Publishing Status</DialogTitle> <DialogTitle>Publishing Status</DialogTitle>
<DialogContent> <DialogContent>
@ -275,12 +278,15 @@ const IndividualResourceComponent = ({ publish, publishKey, publishStatus }: Ind
}, [chunkDone, processingStart]); }, [chunkDone, processingStart]);
// Keep time ticking for progress simulation // Keep time ticking for progress simulation
useEffect(() => { useEffect(() => {
if (!chunkDone) return; if (!chunkDone) return;
const interval = setInterval(() => setNow(Date.now()), 1000);
return () => clearInterval(interval);
}, [chunkDone]);
const interval = setInterval(() => {
setNow(Date.now());
}, 1000);
return () => clearInterval(interval);
}, [chunkDone]);
const processingPercent = useMemo(() => { const processingPercent = useMemo(() => {
if (publishStatus?.error || !chunkDone || !processingStart || !publishStatus?.totalChunks || !now) return 0; if (publishStatus?.error || !chunkDone || !processingStart || !publishStatus?.totalChunks || !now) return 0;
@ -307,9 +313,9 @@ const IndividualResourceComponent = ({ publish, publishKey, publishStatus }: Ind
<Box mt={2}> <Box mt={2}>
<Typography variant="body2" gutterBottom> <Typography variant="body2" gutterBottom>
File Processing ({processingStart ? processingPercent.toFixed(0) : '0'}%) File Processing ({publishStatus?.processed ? 100 : processingStart ? processingPercent.toFixed(0) : '0'}%)
</Typography> </Typography>
<LinearProgress variant="determinate" value={processingPercent} /> <LinearProgress variant="determinate" value={publishStatus?.processed ? 100 : processingPercent} />
</Box> </Box>
{publishStatus?.processed && ( {publishStatus?.processed && (

View File

@ -17,6 +17,7 @@ import { useProgressStore } from "../state/video";
import { GlobalPipPlayer } from "../hooks/useGlobalPipPlayer"; import { GlobalPipPlayer } from "../hooks/useGlobalPipPlayer";
import { Location, NavigateFunction } from "react-router-dom"; import { Location, NavigateFunction } from "react-router-dom";
import { MultiPublishDialog } from "../components/MultiPublish/MultiPublishDialog"; import { MultiPublishDialog } from "../components/MultiPublish/MultiPublishDialog";
import { useMultiplePublishStore } from "../state/multiplePublish";
// ✅ Define Global Context Type // ✅ Define Global Context Type
interface GlobalContextType { interface GlobalContextType {
@ -60,6 +61,7 @@ export const GlobalProvider = ({
}: GlobalProviderProps) => { }: GlobalProviderProps) => {
// ✅ Call hooks and pass in options dynamically // ✅ Call hooks and pass in options dynamically
const auth = useAuth(config?.auth || {}); const auth = useAuth(config?.auth || {});
const isPublishing = useMultiplePublishStore((s)=> s.isPublishing);
const appInfo = useAppInfo(config.appName, config?.publicSalt); const appInfo = useAppInfo(config.appName, config?.publicSalt);
const lists = useResources(); const lists = useResources();
@ -96,7 +98,9 @@ export const GlobalProvider = ({
<GlobalContext.Provider value={contextValue}> <GlobalContext.Provider value={contextValue}>
<GlobalPipPlayer /> <GlobalPipPlayer />
<MultiPublishDialog /> {isPublishing && (
<MultiPublishDialog />
)}
<Toaster <Toaster
position="top-center" position="top-center"
toastOptions={{ toastOptions={{

View File

@ -288,7 +288,7 @@ const publishMultipleResources = useCallback(async (resources: ResourceToPublish
store.setFailedPublishResources([]) store.setFailedPublishResources([])
const lengthOfResources = resources?.length; const lengthOfResources = resources?.length;
const lengthOfTimeout = lengthOfResources * 1200000; // 20 minutes per resource const lengthOfTimeout = lengthOfResources * 1200000; // 20 minutes per resource
console.log('lengthOfTimeout', lengthOfTimeout)
const result = await qortalRequestWithTimeout({ const result = await qortalRequestWithTimeout({
action: "PUBLISH_MULTIPLE_QDN_RESOURCES", action: "PUBLISH_MULTIPLE_QDN_RESOURCES",
resources resources
@ -298,6 +298,7 @@ const publishMultipleResources = useCallback(async (resources: ResourceToPublish
store.reset() store.reset()
storeStatus.reset() storeStatus.reset()
} catch (error: any) { } catch (error: any) {
console.log('timeout555')
const unPublished = error?.error?.unsuccessfulPublishes; const unPublished = error?.error?.unsuccessfulPublishes;
const failedPublishes: QortalGetMetadata[] = [] const failedPublishes: QortalGetMetadata[] = []
if (unPublished && Array.isArray(unPublished)) { if (unPublished && Array.isArray(unPublished)) {