From 537efcc7c43e9761987abee962f82d2a52ac4d70 Mon Sep 17 00:00:00 2001 From: Evie Gauthier Date: Tue, 3 Mar 2026 00:26:22 -0500 Subject: [PATCH] only delete specific parent-child room mapping updates --- src/app/state/room/roomToParents.ts | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/src/app/state/room/roomToParents.ts b/src/app/state/room/roomToParents.ts index 0b40eb9c0..240599886 100644 --- a/src/app/state/room/roomToParents.ts +++ b/src/app/state/room/roomToParents.ts @@ -28,6 +28,11 @@ export type RoomToParentsAction = parent: string; children: string[]; } + | { + type: 'REMOVE_CHILD'; + parent: string; + child: string; + } | { type: 'DELETE'; roomId: string; @@ -50,6 +55,22 @@ export const roomToParentsAtom = atom { + const parents = draftRoomToParents.get(action.child); + if (!parents) return; + parents.delete(action.parent); + if (parents.size === 0) { + draftRoomToParents.delete(action.child); + } else { + draftRoomToParents.set(action.child, parents); + } + }) + ); + return; + } if (action.type === 'DELETE') { set( baseRoomToParents, @@ -100,7 +121,7 @@ export const useBindRoomToParentsAtom = ( if (isValidChild(mEvent)) { setRoomToParents({ type: 'PUT', parent: roomId, children: [childId] }); } else { - setRoomToParents({ type: 'DELETE', roomId: childId }); + setRoomToParents({ type: 'REMOVE_CHILD', parent: roomId, child: childId }); } } }