(
type: string,
specPartsToState: (p: RawSpecParts) => M,
)
| 83 | } |
| 84 | |
| 85 | export 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 | } |
no test coverage detected
searching dependent graphs…