feat: cleanup on discard and confirm
This commit is contained in:
@@ -53,10 +53,8 @@ export const RightSidePanel: React.FC<RightSidePanelProps> = ({ onFinishCapture
|
|||||||
const [isCaptureTextConfirmed, setIsCaptureTextConfirmed] = useState(false);
|
const [isCaptureTextConfirmed, setIsCaptureTextConfirmed] = useState(false);
|
||||||
const [isCaptureListConfirmed, setIsCaptureListConfirmed] = useState(false);
|
const [isCaptureListConfirmed, setIsCaptureListConfirmed] = useState(false);
|
||||||
const { panelHeight } = useBrowserDimensionsStore();
|
const { panelHeight } = useBrowserDimensionsStore();
|
||||||
const [isDOMMode, setIsDOMMode] = useState(false);
|
|
||||||
const [currentSnapshot, setCurrentSnapshot] = useState<any>(null);
|
|
||||||
|
|
||||||
const { lastAction, notify, currentWorkflowActionsState, setCurrentWorkflowActionsState, resetInterpretationLog, currentListActionId, setCurrentListActionId, currentTextActionId, setCurrentTextActionId, currentScreenshotActionId, setCurrentScreenshotActionId } = useGlobalInfoStore();
|
const { lastAction, notify, currentWorkflowActionsState, setCurrentWorkflowActionsState, resetInterpretationLog, currentListActionId, setCurrentListActionId, currentTextActionId, setCurrentTextActionId, currentScreenshotActionId, setCurrentScreenshotActionId, updateDOMMode, currentSnapshot, isDOMMode } = useGlobalInfoStore();
|
||||||
const {
|
const {
|
||||||
getText, startGetText, stopGetText,
|
getText, startGetText, stopGetText,
|
||||||
getList, startGetList, stopGetList,
|
getList, startGetList, stopGetList,
|
||||||
@@ -87,22 +85,20 @@ export const RightSidePanel: React.FC<RightSidePanelProps> = ({ onFinishCapture
|
|||||||
if (socket) {
|
if (socket) {
|
||||||
const domModeHandler = (data: any) => {
|
const domModeHandler = (data: any) => {
|
||||||
if (!data.userId || data.userId === id) {
|
if (!data.userId || data.userId === id) {
|
||||||
setIsDOMMode(true);
|
updateDOMMode(true);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const screenshotModeHandler = (data: any) => {
|
const screenshotModeHandler = (data: any) => {
|
||||||
if (!data.userId || data.userId === id) {
|
if (!data.userId || data.userId === id) {
|
||||||
setIsDOMMode(false);
|
updateDOMMode(false);
|
||||||
setCurrentSnapshot(null);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const domcastHandler = (data: any) => {
|
const domcastHandler = (data: any) => {
|
||||||
if (!data.userId || data.userId === id) {
|
if (!data.userId || data.userId === id) {
|
||||||
if (data.snapshotData && data.snapshotData.snapshot) {
|
if (data.snapshotData && data.snapshotData.snapshot) {
|
||||||
setCurrentSnapshot(data.snapshotData);
|
updateDOMMode(true, data.snapshotData);
|
||||||
setIsDOMMode(true);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -117,7 +113,7 @@ export const RightSidePanel: React.FC<RightSidePanelProps> = ({ onFinishCapture
|
|||||||
socket.off("domcast", domcastHandler);
|
socket.off("domcast", domcastHandler);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}, [socket, id]);
|
}, [socket, id, updateDOMMode]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (socket) {
|
if (socket) {
|
||||||
@@ -461,6 +457,7 @@ export const RightSidePanel: React.FC<RightSidePanelProps> = ({ onFinishCapture
|
|||||||
resetInterpretationLog();
|
resetInterpretationLog();
|
||||||
finishAction('text');
|
finishAction('text');
|
||||||
onFinishCapture();
|
onFinishCapture();
|
||||||
|
clientSelectorGenerator.cleanup();
|
||||||
}, [stopGetText, getTextSettingsObject, socket, browserSteps, confirmedTextSteps, resetInterpretationLog, finishAction, notify, onFinishCapture, t]);
|
}, [stopGetText, getTextSettingsObject, socket, browserSteps, confirmedTextSteps, resetInterpretationLog, finishAction, notify, onFinishCapture, t]);
|
||||||
|
|
||||||
const getListSettingsObject = useCallback(() => {
|
const getListSettingsObject = useCallback(() => {
|
||||||
@@ -513,6 +510,8 @@ export const RightSidePanel: React.FC<RightSidePanelProps> = ({ onFinishCapture
|
|||||||
const stopCaptureAndEmitGetListSettings = useCallback(() => {
|
const stopCaptureAndEmitGetListSettings = useCallback(() => {
|
||||||
const settings = getListSettingsObject();
|
const settings = getListSettingsObject();
|
||||||
|
|
||||||
|
console.log("rrwebSnapshotHandler", settings);
|
||||||
|
|
||||||
const latestListStep = getLatestListStep(browserSteps);
|
const latestListStep = getLatestListStep(browserSteps);
|
||||||
if (latestListStep && settings) {
|
if (latestListStep && settings) {
|
||||||
extractDataClientSide(latestListStep.listSelector!, latestListStep.fields, latestListStep.id);
|
extractDataClientSide(latestListStep.listSelector!, latestListStep.fields, latestListStep.id);
|
||||||
@@ -657,6 +656,7 @@ export const RightSidePanel: React.FC<RightSidePanelProps> = ({ onFinishCapture
|
|||||||
|
|
||||||
setCurrentTextActionId('');
|
setCurrentTextActionId('');
|
||||||
setIsCaptureTextConfirmed(false);
|
setIsCaptureTextConfirmed(false);
|
||||||
|
clientSelectorGenerator.cleanup();
|
||||||
notify('error', t('right_panel.errors.capture_text_discarded'));
|
notify('error', t('right_panel.errors.capture_text_discarded'));
|
||||||
}, [currentTextActionId, browserSteps, stopGetText, deleteStepsByActionId, notify, t]);
|
}, [currentTextActionId, browserSteps, stopGetText, deleteStepsByActionId, notify, t]);
|
||||||
|
|
||||||
@@ -687,6 +687,7 @@ export const RightSidePanel: React.FC<RightSidePanelProps> = ({ onFinishCapture
|
|||||||
setCaptureStage('initial');
|
setCaptureStage('initial');
|
||||||
setCurrentListActionId('');
|
setCurrentListActionId('');
|
||||||
setIsCaptureListConfirmed(false);
|
setIsCaptureListConfirmed(false);
|
||||||
|
clientSelectorGenerator.cleanup();
|
||||||
notify('error', t('right_panel.errors.capture_list_discarded'));
|
notify('error', t('right_panel.errors.capture_list_discarded'));
|
||||||
}, [currentListActionId, browserSteps, stopGetList, deleteStepsByActionId, resetListState, setShowPaginationOptions, setShowLimitOptions, setCaptureStage, notify, t]);
|
}, [currentListActionId, browserSteps, stopGetList, deleteStepsByActionId, resetListState, setShowPaginationOptions, setShowLimitOptions, setCaptureStage, notify, t]);
|
||||||
|
|
||||||
@@ -705,6 +706,7 @@ export const RightSidePanel: React.FC<RightSidePanelProps> = ({ onFinishCapture
|
|||||||
stopGetScreenshot();
|
stopGetScreenshot();
|
||||||
resetInterpretationLog();
|
resetInterpretationLog();
|
||||||
finishAction('screenshot');
|
finishAction('screenshot');
|
||||||
|
clientSelectorGenerator.cleanup();
|
||||||
onFinishCapture();
|
onFinishCapture();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user