mirror of
https://github.com/logseq/logseq.git
synced 2026-05-29 15:09:41 +00:00
- Move plugins.edn to config/ as it is user configuration - Add plugin-config enabled flag and moved plugin enabled - Fixed bugs with manual install - Refactored plugin-config component to have its own listener - Split out shared plugin fns to a common ns - plugin-config shouldn't need to depend on a component like plugin-handler - Bump rewrite-edn to include upstream fix and avoid tons of cljs warnings with earlier versions - Fix react warning introduced outside this PR in ui/icon
28 lines
901 B
Clojure
28 lines
901 B
Clojure
(ns frontend.handler.common.plugin
|
|
"Common plugin related fns for handlers and api"
|
|
(:require [frontend.state :as state]
|
|
[promesa.core :as p]
|
|
[electron.ipc :as ipc]))
|
|
|
|
(defn installed?
|
|
"For the given plugin id, returns boolean indicating if it is installed"
|
|
[id]
|
|
(and (contains? (:plugin/installed-plugins @state/state) (keyword id))
|
|
(get-in @state/state [:plugin/installed-plugins (keyword id) :iir])))
|
|
|
|
(defn install-marketplace-plugin
|
|
"Installs plugin given plugin map with id"
|
|
[{:keys [id] :as mft}]
|
|
(when-not (and (:plugin/installing @state/state)
|
|
(installed? id))
|
|
(p/create
|
|
(fn [resolve]
|
|
(state/set-state! :plugin/installing mft)
|
|
(ipc/ipc :installMarketPlugin mft)
|
|
(resolve id)))))
|
|
|
|
(defn unregister-plugin
|
|
"Unregister and uninstall plugin given plugin id"
|
|
[id]
|
|
(js/LSPluginCore.unregister id))
|