Enhance (UX): Electron loading (fixed) (#10201)

* run use-effect once
pull/10161/head
Konstantinos 2023-09-12 11:05:49 +03:00 committed by GitHub
parent b92d01d5d5
commit a6d9cd8b91
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 2 deletions

View File

@ -6,6 +6,7 @@
["buffer" :as buffer]
["diff-match-patch" :as google-diff]
["electron" :refer [app autoUpdater dialog ipcMain shell]]
["electron-window-state" :as windowStateKeeper]
["fs" :as fs]
["fs-extra" :as fs-extra]
["os" :as os]
@ -618,6 +619,10 @@
(defmethod handle :window-close [^js win]
(.close win))
(defmethod handle :theme-loaded [^js win]
(.manage (windowStateKeeper) win)
(.show win))
;;;;;;;;;;;;;;;;;;;;;;;
;; file-sync-rs-apis ;;
;;;;;;;;;;;;;;;;;;;;;;;

View File

@ -35,6 +35,7 @@
:titleBarStyle "hiddenInset"
:trafficLightPosition {:x 16 :y 16}
:autoHideMenuBar (not mac?)
:show false
:webPreferences
{:plugins true ; pdf
:nodeIntegration false
@ -55,7 +56,6 @@
linux?
(assoc :icon (node-path/join js/__dirname "icons/logseq.png")))
win (BrowserWindow. (clj->js win-opts))]
(.manage win-state win)
(.onBeforeSendHeaders (.. session -defaultSession -webRequest)
(clj->js {:urls (array "*://*.youtube.com/*")})
(fn [^js details callback]

View File

@ -1,5 +1,6 @@
(ns frontend.components.theme
(:require [frontend.extensions.pdf.core :as pdf]
(:require [electron.ipc :as ipc]
[frontend.extensions.pdf.core :as pdf]
[frontend.config :as config]
[frontend.handler.plugin :as plugin-handler]
[frontend.handler.plugin-config :as plugin-config-handler]
@ -35,6 +36,10 @@
#(let [doc js/document.documentElement]
(.setAttribute doc "lang" preferred-language)))
(rum/use-effect!
#(js/setTimeout (fn [] (ipc/ipc "theme-loaded")) 100) ; Wait for the theme to be applied
[])
(rum/use-effect!
#(when (and restored-sidebar?
(mounted-fn))