MCPcopy Create free account
hub / github.com/Acode-Foundation/Acode / onToggleEnabled

Function onToggleEnabled

src/pages/plugins/plugins.js:803–852  ·  view source on GitHub ↗
(id, enabled)

Source from the content-addressed store, hash-verified

801 }
802
803 async function onToggleEnabled(id, enabled) {
804 const disabledMap = settings.value.pluginsDisabled || {};
805
806 if (enabled) {
807 disabledMap[id] = true;
808 settings.update({ pluginsDisabled: disabledMap }, false);
809 window.acode.unmountPlugin(id);
810 window.toast(strings["plugin_disabled"] || "Plugin Disabled");
811 } else {
812 delete disabledMap[id];
813 settings.update({ pluginsDisabled: disabledMap }, false);
814 await loadPlugin(id);
815 window.toast(strings["plugin_enabled"] || "Plugin enabled");
816 }
817
818 // Update the plugin object's state in all plugin arrays
819 const installedPlugin = plugins.installed.find((p) => p.id === id);
820 if (installedPlugin) {
821 installedPlugin.enabled = !enabled;
822 }
823
824 const allPlugin = plugins.all.find((p) => p.id === id);
825 if (allPlugin) {
826 allPlugin.enabled = !enabled;
827 }
828
829 const ownedPlugin = plugins.owned.find((p) => p.id === id);
830 if (ownedPlugin) {
831 ownedPlugin.enabled = !enabled;
832 }
833
834 // Re-render the specific item in all tabs
835 const $installedItem = $list.installed.get(`[data-id="${id}"]`);
836 if ($installedItem && installedPlugin) {
837 const $newItem = <Item {...installedPlugin} updates={updates} />;
838 $installedItem.replaceWith($newItem);
839 }
840
841 const $allItem = $list.all.get(`[data-id="${id}"]`);
842 if ($allItem && allPlugin) {
843 const $newItem = <Item {...allPlugin} updates={updates} />;
844 $allItem.replaceWith($newItem);
845 }
846
847 const $ownedItem = $list.owned.get(`[data-id="${id}"]`);
848 if ($ownedItem && ownedPlugin) {
849 const $newItem = <Item {...ownedPlugin} updates={updates} />;
850 $ownedItem.replaceWith($newItem);
851 }
852 }
853}

Callers

nothing calls this directly

Calls 4

loadPluginFunction · 0.85
unmountPluginMethod · 0.80
updateMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected