( state: UiState, threadId: string, turnId: string, expanded: boolean, )
| 275 | } |
| 276 | |
| 277 | export function setThreadChangedFilesExpanded( |
| 278 | state: UiState, |
| 279 | threadId: string, |
| 280 | turnId: string, |
| 281 | expanded: boolean, |
| 282 | ): UiState { |
| 283 | const currentThreadState = state.threadChangedFilesExpandedById[threadId] ?? {}; |
| 284 | const currentExpanded = currentThreadState[turnId] ?? true; |
| 285 | if (currentExpanded === expanded) { |
| 286 | return state; |
| 287 | } |
| 288 | |
| 289 | if (expanded) { |
| 290 | if (!(turnId in currentThreadState)) { |
| 291 | return state; |
| 292 | } |
| 293 | |
| 294 | const nextThreadState = { ...currentThreadState }; |
| 295 | delete nextThreadState[turnId]; |
| 296 | if (Object.keys(nextThreadState).length === 0) { |
| 297 | const nextState = { ...state.threadChangedFilesExpandedById }; |
| 298 | delete nextState[threadId]; |
| 299 | return { |
| 300 | ...state, |
| 301 | threadChangedFilesExpandedById: nextState, |
| 302 | }; |
| 303 | } |
| 304 | |
| 305 | return { |
| 306 | ...state, |
| 307 | threadChangedFilesExpandedById: { |
| 308 | ...state.threadChangedFilesExpandedById, |
| 309 | [threadId]: nextThreadState, |
| 310 | }, |
| 311 | }; |
| 312 | } |
| 313 | |
| 314 | return { |
| 315 | ...state, |
| 316 | threadChangedFilesExpandedById: { |
| 317 | ...state.threadChangedFilesExpandedById, |
| 318 | [threadId]: { |
| 319 | ...currentThreadState, |
| 320 | [turnId]: false, |
| 321 | }, |
| 322 | }, |
| 323 | }; |
| 324 | } |
| 325 | |
| 326 | export function setDefaultAdvertisedEndpointKey(state: UiState, key: string | null): UiState { |
| 327 | const nextKey = key && key.length > 0 ? key : null; |
no outgoing calls
no test coverage detected