1
0
Эх сурвалжийг харах

Remove state/get-graph-path use from the main menu

Vladimir Pouzanov 1 жил өмнө
parent
commit
0bb7e6d0cc

+ 1 - 1
src/electron/electron/core.cljs

@@ -186,7 +186,7 @@
                        {:role "fileMenu"
                         :submenu [{:label "New Window"
                                    :click (fn []
-                                            (p/let [graph-name (get-graph-name (state/get-graph-path))
+                                            (p/let [graph-name (get-graph-name (state/get-active-window-graph-path))
                                                     _ (handler/broadcast-persist-graph! graph-name)]
                                               (handler/open-new-window!)))
                                    :accelerator (if mac?

+ 10 - 0
src/electron/electron/state.cljs

@@ -48,6 +48,16 @@
   [window]
   (get (:window/graph @state) window))
 
+(defn get-active-window-graph-path
+  "Get the path of the graph of the currently focused window (might be `nil`)"
+  []
+  (let [windows (:window/graph @state)
+        active-windows-pairs (filter #(.isFocused (first %)) windows)
+        active-window-pair (first active-windows-pairs)
+        path (second active-window-pair)]
+    path)
+  )
+
 (defn close-window!
   [window]
   (swap! state medley/dissoc-in [:window/graph window]))