Sfoglia il codice sorgente

fix(pdf): set up initial listeners for the pdf viewer inside system window

charlie 1 anno fa
parent
commit
ef3dc26db9

+ 3 - 0
src/electron/electron/handler.cljs

@@ -729,6 +729,9 @@
 (defmethod handle :server/set-config [^js _win [_ config]]
   (server/set-config! config))
 
+(defmethod handle :window/open-blank-callback [^js win [_ _type]]
+  (win/setup-window-listeners! win) nil)
+
 (defn set-ipc-handler! [window]
   (let [main-channel "main"]
     (.handle ipcMain main-channel

+ 5 - 1
src/main/frontend/extensions/pdf/windows.cljs

@@ -1,6 +1,7 @@
 (ns frontend.extensions.pdf.windows
   (:require [frontend.state :as state]
             [rum.core :as rum]
+            [cljs-bean.core :as bean]
             [frontend.storage :as storage]))
 
 (def *active-win (atom nil))
@@ -103,7 +104,10 @@
                                                                  :y      (.-screenY win)})))
 
                 (reset! *active-win win)
-                (state/set-state! :pdf/system-win? true))))]
+                (state/set-state! :pdf/system-win? true)
+                ;; NOTE: must do ipc in new window
+                (some-> (.-apis win)
+                  (.doAction (bean/->js [:window/open-blank-callback :pdf]))))))]
 
       (js/setTimeout
        (fn []