From 22bb11d563f812f58c30b85e51547cba0b6b76dd Mon Sep 17 00:00:00 2001
From: soryu <soryu@soryu.co>
Date: Wed, 24 Dec 2025 02:04:17 +0000
Subject: Revert "Fixup: Update overwrite mechanism"

This reverts commit 70e6c958a5a624e1d3ce51ff119a281032addf1a.
---
 makima/frontend/src/routes/files.tsx | 16 ++++------------
 1 file changed, 4 insertions(+), 12 deletions(-)

(limited to 'makima/frontend/src/routes/files.tsx')

diff --git a/makima/frontend/src/routes/files.tsx b/makima/frontend/src/routes/files.tsx
index 989ea44..2a75218 100644
--- a/makima/frontend/src/routes/files.tsx
+++ b/makima/frontend/src/routes/files.tsx
@@ -24,12 +24,6 @@ export default function FilesPage() {
   const [hasLocalChanges, setHasLocalChanges] = useState(false);
   const [isActivelyEditing, setIsActivelyEditing] = useState(false);
   const pendingUpdateRef = useRef(false);
-  const remoteUpdateRef = useRef<FileUpdateEvent | null>(null);
-
-  // Keep ref in sync with state to avoid stale closures
-  useEffect(() => {
-    remoteUpdateRef.current = remoteUpdate;
-  }, [remoteUpdate]);
 
   // Load file detail when URL has an id
   useEffect(() => {
@@ -130,9 +124,8 @@ export default function FilesPage() {
         newBody[index] = element;
 
         // If there's a pending remote update, fetch latest version first
-        // Use ref to get current value (avoids stale closure)
         let versionToUse = fileDetail.version;
-        if (remoteUpdateRef.current) {
+        if (remoteUpdate) {
           const latest = await fetchFile(id);
           if (latest) {
             versionToUse = latest.version;
@@ -156,7 +149,7 @@ export default function FilesPage() {
         }
       }
     },
-    [fileDetail, id, editFile, fetchFile]
+    [fileDetail, id, editFile, remoteUpdate, fetchFile]
   );
 
   const handleBodyReorder = useCallback(
@@ -168,9 +161,8 @@ export default function FilesPage() {
         newBody.splice(toIndex, 0, movedElement);
 
         // If there's a pending remote update, fetch latest version first
-        // Use ref to get current value (avoids stale closure)
         let versionToUse = fileDetail.version;
-        if (remoteUpdateRef.current) {
+        if (remoteUpdate) {
           const latest = await fetchFile(id);
           if (latest) {
             versionToUse = latest.version;
@@ -194,7 +186,7 @@ export default function FilesPage() {
         }
       }
     },
-    [fileDetail, id, editFile, fetchFile]
+    [fileDetail, id, editFile, remoteUpdate, fetchFile]
   );
 
   const handleCreate = useCallback(async () => {
-- 
cgit v1.2.3

