MCPcopy Create free account
hub / github.com/EsperoTech/yaade / currentScriptReducer

Function currentScriptReducer

client/src/state/currentScript.tsx:73–90  ·  view source on GitHub ↗
(
  state: CurrentScript | undefined = defaultCurrentScript,
  action: CurrentScriptAction,
)

Source from the content-addressed store, hash-verified

71type CurrentScriptAction = SetAction | UnsetAction | PatchDataAction | SetIsChangedAction;
72
73function currentScriptReducer(
74 state: CurrentScript | undefined = defaultCurrentScript,
75 action: CurrentScriptAction,
76) {
77 switch (action.type) {
78 case CurrentScriptActionType.SET:
79 return set(action.script);
80 case CurrentScriptActionType.UNSET:
81 return unset();
82 case CurrentScriptActionType.PATCH_DATA:
83 return patchData(state, action.data);
84 case CurrentScriptActionType.SET_IS_CHANGED:
85 return setIsChanged(state, action.isChanged);
86 default:
87 console.error('Invalid action type', action);
88 return state;
89 }
90}
91
92export type { CurrentScriptAction };
93

Callers

nothing calls this directly

Calls 4

setFunction · 0.70
unsetFunction · 0.70
patchDataFunction · 0.70
setIsChangedFunction · 0.70

Tested by

no test coverage detected