1
0
Эх сурвалжийг харах

fix(plugin): repeat registration key to plugin ui items

charlie 3 жил өмнө
parent
commit
5b14b6f50f

+ 1 - 1
src/main/frontend/components/plugins.cljs

@@ -814,7 +814,7 @@
        (when-let [^js el (rum/deref *el)]
          (js/LSPlugin.pluginHelpers.setupInjectedUI.call
           pl #js {:slot (.-id el) :key key :template template} #js {})))
-     [])
+     [template])
 
     (if-not (nil? pl)
       [:div

+ 5 - 3
src/main/frontend/handler/plugin.cljs

@@ -317,11 +317,13 @@
   (swap! state/state medley/dissoc-in [:plugin/simple-commands (keyword pid)]))
 
 (defn register-plugin-ui-item
-  [pid {:keys [type] :as opts}]
+  [pid {:keys [key type] :as opts}]
   (when-let [pid (keyword pid)]
     (when (contains? (:plugin/installed-plugins @state/state) pid)
-      (swap! state/state update-in [:plugin/installed-ui-items pid]
-             (fnil conj []) [type opts pid])
+      (let [items (or (get-in @state/state [:plugin/installed-ui-items pid]) [])
+            items (filter #(not= key (:key (second %))) items)]
+        (swap! state/state assoc-in [:plugin/installed-ui-items pid]
+               (conj items [type opts pid])))
       true)))
 
 (defn unregister-plugin-ui-items