From 7fef1ce06d9b48983f3295129dddfab3cd242436 Mon Sep 17 00:00:00 2001
From: Kirill Rogovoy <kirill@rogovoy.me>
Date: Mon, 9 Aug 2021 15:26:06 +0300
Subject: fix: broken lock files + double click

---
 pages/index.tsx | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

(limited to 'pages/index.tsx')

diff --git a/pages/index.tsx b/pages/index.tsx
index 42170a1..e2cda84 100644
--- a/pages/index.tsx
+++ b/pages/index.tsx
@@ -1038,12 +1038,20 @@ export const Graph = forwardRef(function (props: GraphProps, graphRef: any) {
     onNodeClick: (nodeArg: NodeObject, event: any) => {
       const node = nodeArg as OrgRoamNode
       contextMenu.onClose()
-      const isDoubleClick = event.timeStamp - lastNodeClickRef.current < 400
+      const doubleClickTimeBuffer = 200
+      const isDoubleClick = event.timeStamp - lastNodeClickRef.current < doubleClickTimeBuffer
       lastNodeClickRef.current = event.timeStamp
       if (isDoubleClick) {
         return handleClick('double', node, event)
       }
-      return handleClick('click', node, event)
+
+      const prevNodeClickTime = lastNodeClickRef.current
+      return setTimeout(() => {
+        if (lastNodeClickRef.current !== prevNodeClickTime) {
+          return
+        }
+        return handleClick('click', node, event)
+      }, doubleClickTimeBuffer)
     },
     onBackgroundClick: () => {
       contextMenu.onClose()
-- 
cgit v1.2.3

