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

View File

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

View File

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