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

Function updateState

web/src/js/ducks/modes/utils.ts:85–106  ·  view source on GitHub ↗
(
    type: string,
    specPartsToState: (p: RawSpecParts) => M,
)

Source from the content-addressed store, hash-verified

83}
84
85export function updateState<M extends ModeState>(
86 type: string,
87 specPartsToState: (p: RawSpecParts) => M,
88) {
89 return function reducer(
90 state: M[],
91 action: PayloadAction<Partial<BackendState>>,
92 ) {
93 if (action.payload.servers) {
94 const activeSpecs = Object.values(action.payload.servers)
95 .filter((server) => server.type === type)
96 .map((server) => parseSpec(server.full_spec));
97 if (activeSpecs.length > 0) {
98 return activeSpecs.map(specPartsToState);
99 } else {
100 for (const mode of state) {
101 mode.active = false;
102 }
103 }
104 }
105 };
106}

Callers 7

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

Calls 4

parseSpecFunction · 0.90
valuesMethod · 0.80
mapMethod · 0.45
filterMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…