feat: emit screenshot for unique user
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
import React, { useCallback, useEffect, useState } from 'react';
|
import React, { useCallback, useContext, useEffect, useState } from 'react';
|
||||||
import { useSocketStore } from '../../context/socket';
|
import { useSocketStore } from '../../context/socket';
|
||||||
import { Button } from '@mui/material';
|
import { Button } from '@mui/material';
|
||||||
import Canvas from "../recorder/canvas";
|
import Canvas from "../recorder/canvas";
|
||||||
@@ -8,6 +8,7 @@ import { useActionContext } from '../../context/browserActions';
|
|||||||
import { useBrowserSteps, TextStep } from '../../context/browserSteps';
|
import { useBrowserSteps, TextStep } from '../../context/browserSteps';
|
||||||
import { useGlobalInfoStore } from '../../context/globalInfo';
|
import { useGlobalInfoStore } from '../../context/globalInfo';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
|
import { AuthContext } from '../../context/auth';
|
||||||
|
|
||||||
interface ElementInfo {
|
interface ElementInfo {
|
||||||
tagName: string;
|
tagName: string;
|
||||||
@@ -27,6 +28,12 @@ interface AttributeOption {
|
|||||||
value: string;
|
value: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface ScreencastData {
|
||||||
|
image: string;
|
||||||
|
userId: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
const getAttributeOptions = (tagName: string, elementInfo: ElementInfo | null): AttributeOption[] => {
|
const getAttributeOptions = (tagName: string, elementInfo: ElementInfo | null): AttributeOption[] => {
|
||||||
if (!elementInfo) return [];
|
if (!elementInfo) return [];
|
||||||
switch (tagName.toLowerCase()) {
|
switch (tagName.toLowerCase()) {
|
||||||
@@ -72,6 +79,9 @@ export const BrowserWindow = () => {
|
|||||||
const { getText, getList, paginationMode, paginationType, limitMode, captureStage } = useActionContext();
|
const { getText, getList, paginationMode, paginationType, limitMode, captureStage } = useActionContext();
|
||||||
const { addTextStep, addListStep } = useBrowserSteps();
|
const { addTextStep, addListStep } = useBrowserSteps();
|
||||||
|
|
||||||
|
const { state } = useContext(AuthContext);
|
||||||
|
const { user } = state;
|
||||||
|
|
||||||
const onMouseMove = (e: MouseEvent) => {
|
const onMouseMove = (e: MouseEvent) => {
|
||||||
if (canvasRef && canvasRef.current && highlighterData) {
|
if (canvasRef && canvasRef.current && highlighterData) {
|
||||||
const canvasRect = canvasRef.current.getBoundingClientRect();
|
const canvasRect = canvasRef.current.getBoundingClientRect();
|
||||||
@@ -99,9 +109,15 @@ export const BrowserWindow = () => {
|
|||||||
}
|
}
|
||||||
}, [getList, resetListState]);
|
}, [getList, resetListState]);
|
||||||
|
|
||||||
const screencastHandler = useCallback((data: string) => {
|
const screencastHandler = useCallback((data: string | ScreencastData) => {
|
||||||
setScreenShot(data);
|
if (typeof data === 'string') {
|
||||||
}, [screenShot]);
|
setScreenShot(data);
|
||||||
|
} else if (data && typeof data === 'object' && 'image' in data) {
|
||||||
|
if (!data.userId || data.userId === user?.id) {
|
||||||
|
setScreenShot(data.image);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, [screenShot, user?.id]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (socket) {
|
if (socket) {
|
||||||
|
|||||||
Reference in New Issue
Block a user