From ca57d49aa7bdc17af272e4e92613eeba12f6f419 Mon Sep 17 00:00:00 2001
From: sowgro <tpoke.ferrari@gmail.com>
Date: Sat, 18 Jan 2025 19:46:39 -0500
Subject: Prevent simultaneous actions from causing rate limit

---
 extension/src/components/BMEditor.tsx | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)

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

diff --git a/extension/src/components/BMEditor.tsx b/extension/src/components/BMEditor.tsx
index eb84246..d66763e 100644
--- a/extension/src/components/BMEditor.tsx
+++ b/extension/src/components/BMEditor.tsx
@@ -16,7 +16,15 @@ function BMEditor() {
         if (!activeEdit) return;
     }, [activeEdit]);
 
-    let isFolder = activeEdit && activeEdit.children && activeEdit.children.length > 0;
+    function handleTitleChange(e: React.ChangeEvent<HTMLInputElement>) {
+        getBrowser().bookmarks.update(activeEdit!.id, {title: e.target.value})
+    }
+
+    function handleURLChange(e: React.ChangeEvent<HTMLInputElement>) {
+        getBrowser().bookmarks.update(activeEdit!.id, {url: e.target.value})
+    }
+
+    let isFolder = activeEdit && activeEdit.children /*&& activeEdit.children.length > 0;*/
     return (
         <div id="settings-menu" className={activeEdit ? "open" : "closed"}>
             <button id="settings-close" onClick={_ => setActiveEdit(null)}>
@@ -27,15 +35,11 @@ function BMEditor() {
                 <h1>Edit {isFolder ? "Folder" : "Bookmark"}</h1>
 
                 <h3>Name</h3>
-                <input type={"text"} defaultValue={activeEdit?.title} onChange={e => {
-                    getBrowser().bookmarks.update(activeEdit!.id, {title: e.target.value})
-                }}/>
+                <input type={"text"} defaultValue={activeEdit?.title} onBlur={handleTitleChange}/>
 
                 {!isFolder && (<>
                     <h3>URL</h3>
-                    <input type={"url"} defaultValue={activeEdit?.url} onChange={e => {
-                        getBrowser().bookmarks.update(activeEdit!.id, {url: e.target.value})
-                    }}/>
+                    <input type={"url"} defaultValue={activeEdit?.url} onBlur={handleURLChange}/>
                 </>)}
 
                 <h3>Icon</h3>
-- 
cgit v1.2.3

