MCPcopy Create free account
hub / github.com/mitmproxy/mitmproxy / addSetter

Function addSetter

web/src/js/ducks/modes/utils.ts:59–83  ·  view source on GitHub ↗
(
    builder: ActionReducerMapBuilder<M[]>,
    attribute: Attr,
    setThunk: AsyncThunk<
        void,
        { server: ModeState; value: Draft<M>[Attr] },
        AppAsyncThunkConfig
    >,
)

Source from the content-addressed store, hash-verified

57}
58
59export function addSetter<M extends ModeState, Attr extends keyof Draft<M>>(
60 builder: ActionReducerMapBuilder<M[]>,
61 attribute: Attr,
62 setThunk: AsyncThunk<
63 void,
64 { server: ModeState; value: Draft<M>[Attr] },
65 AppAsyncThunkConfig
66 >,
67) {
68 builder.addCase(setThunk.pending, (state, action) => {
69 const { server, value } = action.meta.arg;
70 const idx = state.findIndex((m) => m.ui_id === server.ui_id);
71 if (idx >= 0) {
72 state[idx][attribute] = value;
73 state[idx].error = undefined;
74 }
75 });
76 builder.addCase(setThunk.rejected, (state, action) => {
77 const { server } = action.meta.arg;
78 const idx = state.findIndex((m) => m.ui_id === server.ui_id);
79 if (idx >= 0) {
80 state[idx].error = action.error.message;
81 }
82 });
83}
84
85export function updateState<M extends ModeState>(
86 type: string,

Callers 8

wireguard.tsFile · 0.90
transparent.tsFile · 0.90
upstream.tsFile · 0.90
regular.tsFile · 0.90
reverse.tsFile · 0.90
dns.tsFile · 0.90
socks.tsFile · 0.90
local.tsFile · 0.90

Calls 1

findIndexMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…