diff --git a/src/context/browserActions.tsx b/src/context/browserActions.tsx index 2ab82553..7ff6f377 100644 --- a/src/context/browserActions.tsx +++ b/src/context/browserActions.tsx @@ -3,6 +3,7 @@ import { useSocketStore } from './socket'; export type PaginationType = 'scrollDown' | 'scrollUp' | 'clickNext' | 'clickLoadMore' | 'none' | ''; export type LimitType = '10' | '100' | 'custom' | ''; +export type CaptureStage = 'initial' | 'pagination' | 'limit' | 'complete'; interface ActionContextProps { getText: boolean; @@ -13,6 +14,8 @@ interface ActionContextProps { paginationType: PaginationType; limitType: LimitType; customLimit: string; + captureStage: CaptureStage; // New captureStage property + setCaptureStage: (stage: CaptureStage) => void; // Setter for captureStage startPaginationMode: () => void; startGetText: () => void; stopGetText: () => void; @@ -39,17 +42,26 @@ export const ActionProvider = ({ children }: { children: ReactNode }) => { const [paginationType, setPaginationType] = useState(''); const [limitType, setLimitType] = useState(''); const [customLimit, setCustomLimit] = useState(''); + const [captureStage, setCaptureStage] = useState('initial'); // New captureStage state - const {socket} = useSocketStore(); + const { socket } = useSocketStore(); const updatePaginationType = (type: PaginationType) => setPaginationType(type); const updateLimitType = (type: LimitType) => setLimitType(type); const updateCustomLimit = (limit: string) => setCustomLimit(limit); - const startPaginationMode = () => setPaginationMode(true); + const startPaginationMode = () => { + setPaginationMode(true); + setCaptureStage('pagination'); + }; + const stopPaginationMode = () => setPaginationMode(false); - const startLimitMode = () => setLimitMode(true); + const startLimitMode = () => { + setLimitMode(true); + setCaptureStage('limit'); + }; + const stopLimitMode = () => setLimitMode(false); const startGetText = () => setGetText(true); @@ -59,35 +71,38 @@ export const ActionProvider = ({ children }: { children: ReactNode }) => { setGetList(true); socket?.emit('setGetList', { getList: true }); } - + const stopGetList = () => { setGetList(false); socket?.emit('setGetList', { getList: false }); setPaginationType(''); setLimitType(''); setCustomLimit(''); + setCaptureStage('initial'); // Reset captureStage when stopping getList }; const startGetScreenshot = () => setGetScreenshot(true); const stopGetScreenshot = () => setGetScreenshot(false); return ( - { throw new Error('useActionContext must be used within an ActionProvider'); } return context; -}; \ No newline at end of file +}; diff --git a/src/context/userViewportDimensions.tsx b/src/context/userViewportDimensions.tsx deleted file mode 100644 index 1d6a22ee..00000000 --- a/src/context/userViewportDimensions.tsx +++ /dev/null @@ -1,38 +0,0 @@ -import React, { useState, useEffect } from 'react'; - -interface Dimensions { - width: number; - height: number; -} - -const UserViewportDimensions: React.FC = () => { - const [dimensions, setDimensions] = useState({ - width: window.innerWidth, - height: window.innerHeight, - }); - - const handleResize = () => { - setDimensions({ - width: window.innerWidth, - height: window.innerHeight, - }); - }; - - useEffect(() => { - window.addEventListener('resize', handleResize); - - return () => { - window.removeEventListener('resize', handleResize); - }; - }, []); - - return ( -
-

User Viewport Dimensions

-

Width: {dimensions.width}px

-

Height: {dimensions.height}px

-
- ); -}; - -export default UserViewportDimensions;