Properly handle null tree node name and icon

This commit is contained in:
Philipinho 2025-03-14 22:05:17 +00:00
parent b2767d17c2
commit 823eabe1db
2 changed files with 6 additions and 6 deletions

View File

@ -67,11 +67,11 @@ export function TitleEditor({
if (editor) {
// @ts-ignore
setTitleEditor(editor);
setActivePageId(pageId);
}
},
onUpdate({ editor }) {
debounceUpdate();
setActivePageId(pageId);
},
editable: editable,
content: title,

View File

@ -23,14 +23,14 @@ export const useTreeSocket = () => {
const initialData = initialTreeData.current;
const treeApi = new SimpleTree<SpaceTreeNode>(initialData);
if (treeApi.find(event.id)) {
if (event.payload?.title) {
if (treeApi.find(event?.id)) {
if (event.payload?.title !== undefined) {
treeApi.update({
id: event.id,
changes: { name: event.payload.title },
});
setTreeData(treeApi.data);
}
setTreeData(treeApi.data);
}
};
@ -49,13 +49,13 @@ export const useTreeSocket = () => {
case "updateOne":
if (event.entity[0] === "pages") {
if (treeApi.find(event.id)) {
if (event.payload?.title) {
if (event.payload?.title !== undefined) {
treeApi.update({
id: event.id,
changes: { name: event.payload.title },
});
}
if (event.payload?.icon) {
if (event.payload?.icon !== undefined) {
treeApi.update({
id: event.id,
changes: { icon: event.payload.icon },