feat: emission status
This commit is contained in:
@@ -57,6 +57,7 @@ export const RightSidePanel: React.FC<RightSidePanelProps> = ({ onFinishCapture
|
|||||||
const [hoverStates, setHoverStates] = useState<{ [id: string]: boolean }>({});
|
const [hoverStates, setHoverStates] = useState<{ [id: string]: boolean }>({});
|
||||||
const [pendingEvents, setPendingEvents] = useState<Array<{ action: string; settings: any }>>([]);
|
const [pendingEvents, setPendingEvents] = useState<Array<{ action: string; settings: any }>>([]);
|
||||||
const [isEmittingEvents, setIsEmittingEvents] = useState(false);
|
const [isEmittingEvents, setIsEmittingEvents] = useState(false);
|
||||||
|
const [emissionStatus, setEmissionStatus] = useState<'idle' | 'emitting' | 'done'>('idle');
|
||||||
|
|
||||||
const { lastAction, notify } = useGlobalInfoStore();
|
const { lastAction, notify } = useGlobalInfoStore();
|
||||||
const { getText, startGetText, stopGetText, getScreenshot, startGetScreenshot, stopGetScreenshot, getList, startGetList, stopGetList, startPaginationMode, stopPaginationMode, paginationType, updatePaginationType, limitType, customLimit, updateLimitType, updateCustomLimit, stopLimitMode, startLimitMode } = useActionContext();
|
const { getText, startGetText, stopGetText, getScreenshot, startGetScreenshot, stopGetScreenshot, getList, startGetList, stopGetList, startPaginationMode, stopPaginationMode, paginationType, updatePaginationType, limitType, customLimit, updateLimitType, updateCustomLimit, stopLimitMode, startLimitMode } = useActionContext();
|
||||||
@@ -135,6 +136,7 @@ export const RightSidePanel: React.FC<RightSidePanelProps> = ({ onFinishCapture
|
|||||||
}
|
}
|
||||||
|
|
||||||
setIsEmittingEvents(true);
|
setIsEmittingEvents(true);
|
||||||
|
setEmissionStatus('emitting');
|
||||||
|
|
||||||
const emitEvents = async () => {
|
const emitEvents = async () => {
|
||||||
for (const event of pendingEvents) {
|
for (const event of pendingEvents) {
|
||||||
@@ -146,6 +148,7 @@ export const RightSidePanel: React.FC<RightSidePanelProps> = ({ onFinishCapture
|
|||||||
}
|
}
|
||||||
setPendingEvents([]);
|
setPendingEvents([]);
|
||||||
setIsEmittingEvents(false);
|
setIsEmittingEvents(false);
|
||||||
|
setEmissionStatus('done');
|
||||||
onFinishCapture();
|
onFinishCapture();
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -238,10 +241,14 @@ export const RightSidePanel: React.FC<RightSidePanelProps> = ({ onFinishCapture
|
|||||||
stopGetText();
|
stopGetText();
|
||||||
const settings = getTextSettingsObject();
|
const settings = getTextSettingsObject();
|
||||||
const hasTextSteps = browserSteps.some(step => step.type === 'text');
|
const hasTextSteps = browserSteps.some(step => step.type === 'text');
|
||||||
if (hasTextSteps) {
|
// if (hasTextSteps) {
|
||||||
// socket?.emit('action', { action: 'scrapeSchema', settings });
|
// // socket?.emit('action', { action: 'scrapeSchema', settings });
|
||||||
|
// addPendingEvent('scrapeSchema', settings);
|
||||||
|
// }
|
||||||
|
const textSteps = browserSteps.filter(step => step.type === 'text' && confirmedTextSteps[step.id]);
|
||||||
|
textSteps.forEach(step => {
|
||||||
addPendingEvent('scrapeSchema', settings);
|
addPendingEvent('scrapeSchema', settings);
|
||||||
}
|
});
|
||||||
//onFinishCapture();
|
//onFinishCapture();
|
||||||
}, [stopGetText, getTextSettingsObject, browserSteps, confirmedTextSteps, addPendingEvent]);
|
}, [stopGetText, getTextSettingsObject, browserSteps, confirmedTextSteps, addPendingEvent]);
|
||||||
|
|
||||||
@@ -279,6 +286,15 @@ export const RightSidePanel: React.FC<RightSidePanelProps> = ({ onFinishCapture
|
|||||||
return settings;
|
return settings;
|
||||||
}, [browserSteps, paginationType, limitType, customLimit]);
|
}, [browserSteps, paginationType, limitType, customLimit]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (emissionStatus === 'done') {
|
||||||
|
const timer = setTimeout(() => {
|
||||||
|
setEmissionStatus('idle');
|
||||||
|
}, 3000); // Reset status after 3 seconds
|
||||||
|
return () => clearTimeout(timer);
|
||||||
|
}
|
||||||
|
}, [emissionStatus]);
|
||||||
|
|
||||||
const resetListState = useCallback(() => {
|
const resetListState = useCallback(() => {
|
||||||
setShowPaginationOptions(false);
|
setShowPaginationOptions(false);
|
||||||
updatePaginationType('');
|
updatePaginationType('');
|
||||||
@@ -620,7 +636,9 @@ export const RightSidePanel: React.FC<RightSidePanelProps> = ({ onFinishCapture
|
|||||||
onClick={emitPendingEvents}
|
onClick={emitPendingEvents}
|
||||||
disabled={isEmittingEvents}
|
disabled={isEmittingEvents}
|
||||||
>
|
>
|
||||||
{isEmittingEvents ? 'Emitting Events...' : 'Emit Socket Events'}
|
{emissionStatus === 'idle' && 'Emit Socket Events'}
|
||||||
|
{emissionStatus === 'emitting' && 'Emitting Events...'}
|
||||||
|
{emissionStatus === 'done' && 'Emission Complete'}
|
||||||
</Button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
</Box>
|
</Box>
|
||||||
|
|||||||
Reference in New Issue
Block a user