feat: set capture stage in browser actions context
This commit is contained in:
@@ -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<PaginationType>('');
|
||||
const [limitType, setLimitType] = useState<LimitType>('');
|
||||
const [customLimit, setCustomLimit] = useState<string>('');
|
||||
const [captureStage, setCaptureStage] = useState<CaptureStage>('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);
|
||||
@@ -66,6 +78,7 @@ export const ActionProvider = ({ children }: { children: ReactNode }) => {
|
||||
setPaginationType('');
|
||||
setLimitType('');
|
||||
setCustomLimit('');
|
||||
setCaptureStage('initial'); // Reset captureStage when stopping getList
|
||||
};
|
||||
|
||||
const startGetScreenshot = () => setGetScreenshot(true);
|
||||
@@ -81,6 +94,8 @@ export const ActionProvider = ({ children }: { children: ReactNode }) => {
|
||||
paginationType,
|
||||
limitType,
|
||||
customLimit,
|
||||
captureStage,
|
||||
setCaptureStage,
|
||||
startGetText,
|
||||
stopGetText,
|
||||
startGetList,
|
||||
|
||||
@@ -1,38 +0,0 @@
|
||||
import React, { useState, useEffect } from 'react';
|
||||
|
||||
interface Dimensions {
|
||||
width: number;
|
||||
height: number;
|
||||
}
|
||||
|
||||
const UserViewportDimensions: React.FC = () => {
|
||||
const [dimensions, setDimensions] = useState<Dimensions>({
|
||||
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 (
|
||||
<div>
|
||||
<h1>User Viewport Dimensions</h1>
|
||||
<p>Width: {dimensions.width}px</p>
|
||||
<p>Height: {dimensions.height}px</p>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default UserViewportDimensions;
|
||||
Reference in New Issue
Block a user