feat: Implement wall asset management APIs and socket integration for create, update, and delete operations

This commit is contained in:
2025-07-02 10:49:07 +05:30
parent d6f6c4c901
commit 64d086f808
9 changed files with 257 additions and 21 deletions

View File

@@ -5,9 +5,9 @@ interface WallAssetStore {
wallAssets: WallAsset[];
setWallAssets: (assets: WallAsset[]) => void;
addWallAsset: (asset: WallAsset) => void;
updateWallAsset: (uuid: string, updated: Partial<WallAsset>) => void;
updateWallAsset: (uuid: string, updated: Partial<WallAsset>) => WallAsset | undefined;
setWallAssetPosition: (uuid: string, position: [number, number, number]) => void;
removeWallAsset: (uuid: string) => void;
removeWallAsset: (uuid: string) => WallAsset | undefined;
clearWallAssets: () => void;
setVisibility: (uuid: string, isVisible: boolean) => void;
@@ -31,12 +31,17 @@ export const createWallAssetStore = () => {
state.wallAssets.push(asset);
}),
updateWallAsset: (uuid, updated) => set(state => {
const asset = state.wallAssets.find(a => a.modelUuid === uuid);
if (asset) {
Object.assign(asset, updated);
}
}),
updateWallAsset: (uuid, updated) => {
let updatedWallAsset: WallAsset | undefined;
set(state => {
const asset = state.wallAssets.find(a => a.modelUuid === uuid);
if (asset) {
Object.assign(asset, updated);
updatedWallAsset = JSON.parse(JSON.stringify(asset));
}
});
return updatedWallAsset;
},
setWallAssetPosition: (uuid, position) => set(state => {
const asset = state.wallAssets.find(a => a.modelUuid === uuid);
@@ -45,9 +50,17 @@ export const createWallAssetStore = () => {
}
}),
removeWallAsset: (uuid) => set(state => {
state.wallAssets = state.wallAssets.filter(a => a.modelUuid !== uuid);
}),
removeWallAsset: (uuid) => {
let removedAsset: WallAsset | undefined;
set(state => {
const asset = state.wallAssets.find(a => a.modelUuid === uuid);
if (asset) {
removedAsset = JSON.parse(JSON.stringify(asset));
state.wallAssets = state.wallAssets.filter(a => a.modelUuid !== uuid);
}
});
return removedAsset;
},
clearWallAssets: () => {
set(state => {