( state: PersistedUiState, )
| 240 | } |
| 241 | |
| 242 | export function sanitizePersistedUiState( |
| 243 | state: PersistedUiState, |
| 244 | ): PersistedUiState { |
| 245 | const viewportByUDID = Object.fromEntries( |
| 246 | Object.entries(state.viewportByUDID ?? {}) |
| 247 | .map(([udid, viewport]) => [udid, sanitizeViewportState(viewport)]) |
| 248 | .filter((entry): entry is [string, PersistedViewportState] => |
| 249 | Boolean(entry[1]), |
| 250 | ), |
| 251 | ); |
| 252 | |
| 253 | return { |
| 254 | accessibilitySelectedByUDID: state.accessibilitySelectedByUDID ?? {}, |
| 255 | bundleIDValue: stringOrUndefined(state.bundleIDValue), |
| 256 | openURLValue: stringOrUndefined(state.openURLValue), |
| 257 | search: stringOrUndefined(state.search), |
| 258 | selectedUDID: stringOrUndefined(state.selectedUDID), |
| 259 | viewportByUDID, |
| 260 | }; |
| 261 | } |
| 262 | |
| 263 | function sanitizeViewportState( |
| 264 | state: PersistedViewportState | undefined, |
no test coverage detected