Skip to content

Commit 85d30fa

Browse files
committed
cleanup
1 parent b8b4940 commit 85d30fa

File tree

4 files changed

+16
-12
lines changed

4 files changed

+16
-12
lines changed

sites/preview/src/lib/components/tree/NameConflictDialog.svelte

-4
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,6 @@
1616
}
1717
1818
export function show(args: ShowArgs): void {
19-
if (showArgs !== undefined) {
20-
throw new Error("Dialog is already open");
21-
}
22-
2319
showArgs = args;
2420
}
2521

sites/preview/src/lib/components/tree/NameFormDialog.svelte

-4
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,6 @@
1919
}
2020
2121
export function show(args: ShowArgs): void {
22-
if (showArgs !== undefined) {
23-
throw new Error("Dialog is already open");
24-
}
25-
2622
showArgs = args;
2723
name = args.initialName;
2824
}

sites/preview/src/lib/components/tree/Tree.svelte

+11-3
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,12 @@
120120
title: "Rename",
121121
initialName: target.node.name,
122122
onSubmit: async (name) => {
123+
if (nameFormDialog === null) {
124+
throw new Error("Dialog is not mounted");
125+
}
126+
123127
if (name === target.node.name) {
124-
nameFormDialog?.close();
128+
nameFormDialog.close();
125129
return;
126130
}
127131
@@ -135,7 +139,7 @@
135139
136140
const didRename = await onRenameItem({ target, name });
137141
if (didRename) {
138-
nameFormDialog?.close();
142+
nameFormDialog.close();
139143
}
140144
},
141145
});
@@ -185,6 +189,10 @@
185189
title: "New Folder",
186190
initialName: "",
187191
onSubmit: (name) => {
192+
if (nameFormDialog === null) {
193+
throw new Error("Dialog is not mounted");
194+
}
195+
188196
for (const child of target.children) {
189197
if (child.name === name) {
190198
showAlreadyExistsToast(name);
@@ -198,7 +206,7 @@
198206
children: [],
199207
});
200208
target.children.push(node);
201-
nameFormDialog?.close();
209+
nameFormDialog.close();
202210
},
203211
});
204212
}

sites/preview/src/lib/components/tree/TreeItem.svelte

+5-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,11 @@
7373
7474
$effect(() => {
7575
return () => {
76-
contextMenu?.onItemDestroyed(item);
76+
if (contextMenu === null) {
77+
throw new Error("Context menu is not mounted");
78+
}
79+
80+
contextMenu.onItemDestroyed(item);
7781
};
7882
});
7983
</script>

0 commit comments

Comments
 (0)