Refactor App.tsx, brush-command-helpers.ts, editor-store.test.ts, and local-draft-storage.test.ts
This commit is contained in:
@@ -128,15 +128,7 @@ export function App({ store, initialStatusMessage }: AppProps) {
|
|||||||
|
|
||||||
setPositionDraft(createVec3Draft(selectedBrush.center));
|
setPositionDraft(createVec3Draft(selectedBrush.center));
|
||||||
setSizeDraft(createVec3Draft(selectedBrush.size));
|
setSizeDraft(createVec3Draft(selectedBrush.size));
|
||||||
}, [
|
}, [selectedBrush]);
|
||||||
selectedBrush?.id,
|
|
||||||
selectedBrush?.center.x,
|
|
||||||
selectedBrush?.center.y,
|
|
||||||
selectedBrush?.center.z,
|
|
||||||
selectedBrush?.size.x,
|
|
||||||
selectedBrush?.size.y,
|
|
||||||
selectedBrush?.size.z
|
|
||||||
]);
|
|
||||||
|
|
||||||
const applySceneName = () => {
|
const applySceneName = () => {
|
||||||
const normalizedName = sceneNameDraft.trim() || "Untitled Scene";
|
const normalizedName = sceneNameDraft.trim() || "Untitled Scene";
|
||||||
|
|||||||
@@ -38,7 +38,10 @@ export function replaceBrush(document: SceneDocument, brush: BoxBrush): SceneDoc
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function removeBrush(document: SceneDocument, brushId: string): SceneDocument {
|
export function removeBrush(document: SceneDocument, brushId: string): SceneDocument {
|
||||||
const { [brushId]: _removedBrush, ...remainingBrushes } = document.brushes;
|
const remainingBrushes = {
|
||||||
|
...document.brushes
|
||||||
|
};
|
||||||
|
delete remainingBrushes[brushId];
|
||||||
|
|
||||||
return {
|
return {
|
||||||
...document,
|
...document,
|
||||||
|
|||||||
@@ -22,15 +22,15 @@ class MemoryStorage implements KeyValueStorage {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class ThrowingStorage implements KeyValueStorage {
|
class ThrowingStorage implements KeyValueStorage {
|
||||||
getItem(_key: string): string | null {
|
getItem(): string | null {
|
||||||
throw new Error("blocked read");
|
throw new Error("blocked read");
|
||||||
}
|
}
|
||||||
|
|
||||||
setItem(_key: string, _value: string): void {
|
setItem(): void {
|
||||||
throw new Error("blocked write");
|
throw new Error("blocked write");
|
||||||
}
|
}
|
||||||
|
|
||||||
removeItem(_key: string): void {}
|
removeItem(): void {}
|
||||||
}
|
}
|
||||||
|
|
||||||
describe("EditorStore", () => {
|
describe("EditorStore", () => {
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ class ThrowingStorage implements KeyValueStorage {
|
|||||||
} = {}
|
} = {}
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
getItem(_key: string): string | null {
|
getItem(): string | null {
|
||||||
if (this.options.onGetItem !== undefined) {
|
if (this.options.onGetItem !== undefined) {
|
||||||
throw this.options.onGetItem;
|
throw this.options.onGetItem;
|
||||||
}
|
}
|
||||||
@@ -43,13 +43,13 @@ class ThrowingStorage implements KeyValueStorage {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
setItem(_key: string, _value: string): void {
|
setItem(): void {
|
||||||
if (this.options.onSetItem !== undefined) {
|
if (this.options.onSetItem !== undefined) {
|
||||||
throw this.options.onSetItem;
|
throw this.options.onSetItem;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
removeItem(_key: string): void {
|
removeItem(): void {
|
||||||
if (this.options.onRemoveItem !== undefined) {
|
if (this.options.onRemoveItem !== undefined) {
|
||||||
throw this.options.onRemoveItem;
|
throw this.options.onRemoveItem;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user