From 3b8758c14e668e1f57af8f7424442ebca22017c3 Mon Sep 17 00:00:00 2001
From: sowgro <tpoke.ferrari@gmail.com>
Date: Sat, 18 Jan 2025 15:41:42 -0500
Subject: Fix bmEditing without refresh

---
 extension/src/components/FolderBody.tsx | 20 ++++++++++++++------
 1 file changed, 14 insertions(+), 6 deletions(-)

(limited to 'extension/src/components/FolderBody.tsx')

diff --git a/extension/src/components/FolderBody.tsx b/extension/src/components/FolderBody.tsx
index 9b7c5f4..0d9ddec 100644
--- a/extension/src/components/FolderBody.tsx
+++ b/extension/src/components/FolderBody.tsx
@@ -27,10 +27,18 @@ function FolderBody (props: {id: string}) {
 
     useEffect(() => {
         updateBookmarks();
-        // getBrowser().bookmarks.onRemoved.addListener((id: string, moveInfo) => {
-        //     if (moveInfo.parentId !== props.id) return;
-        //     updateBookmarks();
-        // })
+        getBrowser().bookmarks.onRemoved.addListener((id: string, moveInfo) => {
+            if (moveInfo.parentId !== props.id) return;
+            updateBookmarks();
+        })
+        getBrowser().bookmarks.onMoved.addListener((id: string, moveInfo) => {
+            if (moveInfo.parentId !== props.id && moveInfo.oldParentId !== props.id ) return;
+            updateBookmarks();
+        })
+        getBrowser().bookmarks.onCreated.addListener((id: string, moveInfo) => {
+            if (moveInfo.parentId !== props.id) return;
+            updateBookmarks();
+        })
     }, []);
 
     useEffect(() => {
@@ -43,8 +51,8 @@ function FolderBody (props: {id: string}) {
         <div className={"folderBody"}>
             {children.map(child =>
                 child.children
-                    ? <FolderButton id={child.id} />
-                    : <Bookmark id={child.id} />
+                    ? <FolderButton id={child.id} key={child.id}/>
+                    : <Bookmark id={child.id} key={child.id}/>
             )}
         </div>
     )
-- 
cgit v1.2.3

