MCPcopy Create free account
hub / github.com/scriptscat/scriptcat / enableScripts

Function enableScripts

src/pages/options/routes/ScriptList/hooks.tsx:141–157  ·  view source on GitHub ↗
(data: TEnableScript[])

Source from the content-addressed store, hash-verified

139 });
140 },
141 enableScripts(data: TEnableScript[]) {
142 const map = new Map(data.map((d) => [d.uuid, d.enable]));
143 setScriptList((list) => {
144 let changed = false;
145 const newList = list.map((s) => {
146 if (map.has(s.uuid)) {
147 const nextStatus = map.get(s.uuid) ? SCRIPT_STATUS_ENABLE : SCRIPT_STATUS_DISABLE;
148 if (s.status !== nextStatus || s.enableLoading) {
149 changed = true;
150 return { ...s, status: nextStatus, enableLoading: false };
151 }
152 }
153 return s;
154 });
155 return changed ? newList : list;
156 });
157 },
158 sortedScripts(sorting: TSortedScript[]) {
159 setScriptList((list) => {
160 const orderChanged = list.map((s) => s.uuid).join(",") !== sorting.map((s) => s.uuid).join(",");

Callers

nothing calls this directly

Calls 2

hasMethod · 0.65
getMethod · 0.65

Tested by

no test coverage detected