diff --git a/src/main/frontend/components/plugins.cljs b/src/main/frontend/components/plugins.cljs index ae07c2ebd..2d7d462d3 100644 --- a/src/main/frontend/components/plugins.cljs +++ b/src/main/frontend/components/plugins.cljs @@ -23,6 +23,12 @@ (declare open-waiting-updates-modal!) (defonce PER-PAGE-SIZE 15) +(def *dirties-toggle-items (atom {})) + +(defn- clear-dirties-states! + [] + (reset! *dirties-toggle-items {})) + (rum/defcs installed-themes < (rum/local [] ::themes) @@ -272,7 +278,9 @@ (ui/toggle (not disabled?) (fn [] - (js-invoke js/LSPluginCore (if disabled? "enable" "disable") id)) + (js-invoke js/LSPluginCore (if disabled? "enable" "disable") id) + (when (nil? (get @*dirties-toggle-items (keyword id))) + (swap! *dirties-toggle-items assoc (keyword id) (not disabled?)))) true)]]) (defn get-open-plugin-readme-handler @@ -796,11 +804,15 @@ filtered-plugins) sorted-plugins (if default-filter-by? (->> filtered-plugins - (reduce #(let [k (if (get-in %2 [:settings :disabled]) 1 0)] + (reduce #(let [disabled? (get-in %2 [:settings :disabled]) + old-dirty (get @*dirties-toggle-items (keyword (:id %2))) + k (if (if (boolean? old-dirty) (not old-dirty) disabled?) 1 0)] (update %1 k conj %2)) [[] []]) (#(update % 0 (fn [coll] (sort-by :iir coll)))) (flatten)) - filtered-plugins) + (do + (clear-dirties-states!) + filtered-plugins)) fn-query-flag (fn [] (string/join "_" (map #(str @%) [*filter-by *sort-by *search-key *category]))) str-query-flag (fn-query-flag) @@ -1120,9 +1132,15 @@ *el-ref (rum/create-ref)] (rum/use-effect! - #(state/load-app-user-cfgs) + (fn [] + (state/load-app-user-cfgs) + #(clear-dirties-states!)) []) + (rum/use-effect! + #(clear-dirties-states!) + [market?]) + [:div.cp__plugins-page {:ref *el-ref :tab-index "-1"}