Revert "chore: add confirmation dialog"

This reverts commit 0389aeac43.
pull/6950/head
Konstantinos Kaloutas 2022-10-13 12:43:58 +03:00 committed by Tienson Qin
parent 46ef0b5451
commit 118a0dd10c
1 changed files with 19 additions and 30 deletions

View File

@ -4,10 +4,9 @@
[electron.configs :as cfgs]
[electron.context-menu :as context-menu]
[electron.logger :as logger]
["electron" :refer [BrowserWindow app session shell dialog] :as electron]
["electron" :refer [BrowserWindow app session shell] :as electron]
["path" :as path]
["url" :as URL]
[promesa.core :as p]
[electron.state :as state]
[clojure.core.async :as async]
[clojure.string :as string]))
@ -25,23 +24,23 @@
([url]
(let [win-state (windowStateKeeper (clj->js {:defaultWidth 980 :defaultHeight 700}))
win-opts (cond->
{:width (.-width win-state)
:height (.-height win-state)
:frame true
:titleBarStyle "hiddenInset"
:trafficLightPosition {:x 16 :y 16}
:autoHideMenuBar (not mac?)
:webPreferences
{:plugins true ; pdf
:nodeIntegration false
:nodeIntegrationInWorker false
:webSecurity (not dev?)
:contextIsolation true
:spellcheck ((fnil identity true) (cfgs/get-item :spell-check))
{:width (.-width win-state)
:height (.-height win-state)
:frame true
:titleBarStyle "hiddenInset"
:trafficLightPosition {:x 16 :y 16}
:autoHideMenuBar (not mac?)
:webPreferences
{:plugins true ; pdf
:nodeIntegration false
:nodeIntegrationInWorker false
:webSecurity (not dev?)
:contextIsolation true
:spellcheck ((fnil identity true) (cfgs/get-item :spell-check))
;; Remove OverlayScrollbars and transition `.scrollbar-spacing`
;; to use `scollbar-gutter` after the feature is implemented in browsers.
:enableBlinkFeatures 'OverlayScrollbars'
:preload (path/join js/__dirname "js/preload.js")}}
:enableBlinkFeatures 'OverlayScrollbars'
:preload (path/join js/__dirname "js/preload.js")}}
linux?
(assoc :icon (path/join js/__dirname "icons/logseq.png")))
win (BrowserWindow. (clj->js win-opts))]
@ -54,8 +53,8 @@
origin (.-origin urlObj)
requestHeaders (.-requestHeaders details)]
(if (and
(.hasOwnProperty requestHeaders "referer")
(not-empty (.-referer requestHeaders)))
(.hasOwnProperty requestHeaders "referer")
(not-empty (.-referer requestHeaders)))
(callback #js {:cancel false
:requestHeaders requestHeaders})
(do
@ -109,15 +108,6 @@
(not= (.-id win) (.-id window))))
windows))))
(defn unknown-protocol-open!
[protocol url default-open]
(p/let [result (.showMessageBox dialog (clj->js {:title "Unknown protocol"
:type "warning"
:message (str url "\nYou are trying to open a() " protocol " url. Are you sure you want to continue?")
:buttons ["Yes","No"]}))]
(when (zero? (.-response result))
(default-open url))))
(defn- open-default-app!
[url default-open]
(let [URL (.-URL URL)
@ -125,8 +115,7 @@
(when parsed-url
(condp contains? (.-protocol parsed-url)
#{"https:" "http:" "mailto:"} (.openExternal shell url)
#{"file:" "zotero:"} (when (empty? (.-host parsed-url)) (default-open url))
(unknown-protocol-open! (.-protocol parsed-url) url default-open)))))
(default-open url)))))
(defn setup-window-listeners!
[^js win]