mirror of
https://github.com/logseq/logseq.git
synced 2026-04-30 17:06:23 +00:00
Fix more bugs, move plugins.edn and add enabled
- 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
This commit is contained in:
27
src/main/frontend/handler/common/plugin.cljs
Normal file
27
src/main/frontend/handler/common/plugin.cljs
Normal file
@@ -0,0 +1,27 @@
|
||||
(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))
|
||||
Reference in New Issue
Block a user