refactor: Remove unnecessary setIsPlaying calls and clean up event handling in simulation components
This commit is contained in:
parent
e2ef19ca4e
commit
5f9d2b4106
|
@ -22,7 +22,6 @@ function ComparisonScene() {
|
||||||
const product = products.find((product) => product.productName === option);
|
const product = products.find((product) => product.productName === option);
|
||||||
if (product) {
|
if (product) {
|
||||||
setComparisonProduct(product.productUuid, product.productName);
|
setComparisonProduct(product.productUuid, product.productName);
|
||||||
setIsPlaying(true);
|
|
||||||
setIsPaused(true);
|
setIsPaused(true);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -118,7 +118,6 @@ const CompareLayOut = () => {
|
||||||
if (product) {
|
if (product) {
|
||||||
setComparisonProduct(product.productUuid, product.productName);
|
setComparisonProduct(product.productUuid, product.productName);
|
||||||
setLoadingProgress(1);
|
setLoadingProgress(1);
|
||||||
setIsPlaying(true);
|
|
||||||
setIsPaused(true);
|
setIsPaused(true);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -59,6 +59,9 @@ const SimulationPlayer: React.FC = () => {
|
||||||
};
|
};
|
||||||
const handlePlayStop = () => {
|
const handlePlayStop = () => {
|
||||||
setIsPaused(!isPaused);
|
setIsPaused(!isPaused);
|
||||||
|
if (isPaused) {
|
||||||
|
setIsPlaying(true);
|
||||||
|
}
|
||||||
echo.warn(`Simulation is ${isPaused ? "Resumed" : "Paused"}`);
|
echo.warn(`Simulation is ${isPaused ? "Resumed" : "Paused"}`);
|
||||||
};
|
};
|
||||||
const handleExit = () => {
|
const handleExit = () => {
|
||||||
|
|
|
@ -15,6 +15,7 @@ function Simulator() {
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!isPlaying || isReset || !selectedProduct.productUuid) return;
|
if (!isPlaying || isReset || !selectedProduct.productUuid) return;
|
||||||
|
console.log('selectedProduct: ', selectedProduct);
|
||||||
|
|
||||||
const product = getProductById(selectedProduct.productUuid);
|
const product = getProductById(selectedProduct.productUuid);
|
||||||
if (!product) return;
|
if (!product) return;
|
||||||
|
|
|
@ -8,11 +8,20 @@ import DashboardTrash from "../components/Dashboard/DashboardTrash";
|
||||||
import { getUserData } from "../components/Dashboard/functions/getUserData";
|
import { getUserData } from "../components/Dashboard/functions/getUserData";
|
||||||
import SidePannel from "../components/Dashboard/SidePannel";
|
import SidePannel from "../components/Dashboard/SidePannel";
|
||||||
import DashboardTutorial from "../components/Dashboard/DashboardTutorial";
|
import DashboardTutorial from "../components/Dashboard/DashboardTutorial";
|
||||||
|
import { useProductStore } from "../store/simulation/useProductStore";
|
||||||
|
import { useEventsStore } from "../store/simulation/useEventsStore";
|
||||||
|
|
||||||
const Dashboard: React.FC = () => {
|
const Dashboard: React.FC = () => {
|
||||||
const [activeTab, setActiveTab] = useState<string>("Home");
|
const [activeTab, setActiveTab] = useState<string>("Home");
|
||||||
const { socket } = useSocketStore();
|
const { socket } = useSocketStore();
|
||||||
const { userId, organization, email, userName } = getUserData();
|
const { userId, organization, email, userName } = getUserData();
|
||||||
|
const { clearProducts } = useProductStore();
|
||||||
|
const { clearEvents } = useEventsStore();
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
clearEvents();
|
||||||
|
clearProducts();
|
||||||
|
}, [])
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const token = localStorage.getItem("token");
|
const token = localStorage.getItem("token");
|
||||||
|
|
|
@ -34,7 +34,6 @@ import { setFloorItemApi } from "../services/factoryBuilder/assest/floorAsset/se
|
||||||
import { useAssetsStore } from "../store/builder/useAssetStore";
|
import { useAssetsStore } from "../store/builder/useAssetStore";
|
||||||
import ComparisonSceneProvider from "../components/layout/scenes/ComparisonSceneProvider";
|
import ComparisonSceneProvider from "../components/layout/scenes/ComparisonSceneProvider";
|
||||||
import MainSceneProvider from "../components/layout/scenes/MainSceneProvider";
|
import MainSceneProvider from "../components/layout/scenes/MainSceneProvider";
|
||||||
import { useEventsStore } from "../store/simulation/useEventsStore";
|
|
||||||
|
|
||||||
const Project: React.FC = () => {
|
const Project: React.FC = () => {
|
||||||
let navigate = useNavigate();
|
let navigate = useNavigate();
|
||||||
|
@ -47,8 +46,7 @@ const Project: React.FC = () => {
|
||||||
const { setWallItems } = useWallItems();
|
const { setWallItems } = useWallItems();
|
||||||
const { setZones } = useZones();
|
const { setZones } = useZones();
|
||||||
const { isVersionSaved } = useSaveVersion();
|
const { isVersionSaved } = useSaveVersion();
|
||||||
const { setProducts, clearProducts } = useProductStore();
|
const { setProducts } = useProductStore();
|
||||||
const { clearEvents } = useEventsStore();
|
|
||||||
const { projectId } = useParams();
|
const { projectId } = useParams();
|
||||||
const { setProjectName } = useProjectName();
|
const { setProjectName } = useProjectName();
|
||||||
|
|
||||||
|
@ -107,8 +105,6 @@ const Project: React.FC = () => {
|
||||||
setWallItems([]);
|
setWallItems([]);
|
||||||
setZones([]);
|
setZones([]);
|
||||||
setProducts([]);
|
setProducts([]);
|
||||||
clearProducts();
|
|
||||||
clearEvents();
|
|
||||||
setActiveModule("builder");
|
setActiveModule("builder");
|
||||||
const email = localStorage.getItem("email");
|
const email = localStorage.getItem("email");
|
||||||
if (email) {
|
if (email) {
|
||||||
|
|
Loading…
Reference in New Issue