feat: Enhance conveyor and material handling with pause functionality and state management
This commit is contained in:
@@ -33,6 +33,7 @@ type MaterialsStore = {
|
||||
setWeight: (materialId: string, weight: number) => MaterialSchema | undefined;
|
||||
setIsActive: (materialId: string, isActive: boolean) => MaterialSchema | undefined;
|
||||
setIsVisible: (materialId: string, isVisible: boolean) => MaterialSchema | undefined;
|
||||
setIsPaused: (materialId: string, isPlaying: boolean) => MaterialSchema | undefined;
|
||||
setIsRendered: (materialId: string, isRendered: boolean) => MaterialSchema | undefined;
|
||||
|
||||
getMaterialById: (materialId: string) => MaterialSchema | undefined;
|
||||
@@ -192,6 +193,18 @@ export const useMaterialStore = create<MaterialsStore>()(
|
||||
return updatedMaterial;
|
||||
},
|
||||
|
||||
setIsPaused: (materialId, isPaused) => {
|
||||
let updatedMaterial: MaterialSchema | undefined;
|
||||
set((state) => {
|
||||
const material = state.materials.find(m => m.materialId === materialId);
|
||||
if (material) {
|
||||
material.isPaused = isPaused;
|
||||
updatedMaterial = JSON.parse(JSON.stringify(material));
|
||||
};
|
||||
});
|
||||
return updatedMaterial;
|
||||
},
|
||||
|
||||
setIsRendered: (materialId, isRendered) => {
|
||||
let updatedMaterial: MaterialSchema | undefined;
|
||||
set((state) => {
|
||||
|
||||
Reference in New Issue
Block a user