Skip to content

Commit ba3f6f2

Browse files
committed
ENG-1757 Refresh relation state after relation mutations
1 parent b7ee062 commit ba3f6f2

1 file changed

Lines changed: 13 additions & 16 deletions

File tree

apps/roam/src/components/settings/DiscourseRelationConfigPanel.tsx

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1037,12 +1037,15 @@ const DiscourseRelationConfigPanel = ({
10371037
};
10381038

10391039
const handleDelete = (rel: Relation) => {
1040-
deleteBlock(rel.uid);
1041-
setRelations(relations.filter((r) => r.uid !== rel.uid));
1042-
1043-
// eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/naming-convention
1044-
const { [rel.uid]: _, ...remaining } = getGlobalSettings().Relations;
1045-
setGlobalSetting([GLOBAL_KEYS.relations], remaining);
1040+
void deleteBlock(rel.uid).then(() => {
1041+
// eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/naming-convention
1042+
const { [rel.uid]: _, ...remaining } = getGlobalSettings().Relations;
1043+
setGlobalSetting([GLOBAL_KEYS.relations], remaining);
1044+
setTimeout(() => {
1045+
refreshConfigTree();
1046+
setRelations(refreshRelations());
1047+
}, 50);
1048+
});
10461049
};
10471050
const handleDuplicate = (rel: Relation) => {
10481051
const text = rel.text;
@@ -1067,16 +1070,10 @@ const DiscourseRelationConfigPanel = ({
10671070
label: text,
10681071
});
10691072
}
1070-
1071-
setRelations([
1072-
...relations,
1073-
{
1074-
uid: newUid,
1075-
source: rel.source,
1076-
destination: rel.destination,
1077-
text,
1078-
},
1079-
]);
1073+
setTimeout(() => {
1074+
refreshConfigTree();
1075+
setRelations(refreshRelations());
1076+
}, 50);
10801077
});
10811078
};
10821079
const handleBack = () => {

0 commit comments

Comments
 (0)