|
| 1 | +// SPDX-License-Identifier: PMPL-1.0-or-later |
| 2 | + |
| 3 | +/// Extracted sub-updater for VideoCoordination panel. |
| 4 | +/// Manages batch transfer lifecycle, status polling, and error handling. |
| 5 | + |
| 6 | +open Model |
| 7 | +open Msg |
| 8 | + |
| 9 | +let updateVideoCoordination = (model: model, subMsg: videoCoordinationMsg): (model, Tea_Cmd.t<msg>) => { |
| 10 | + let vc = model.videoCoordination |
| 11 | + switch subMsg { |
| 12 | + | StartTransfer(source, destination) => |
| 13 | + let newState = VideoCoordinationEngine.addBatch(vc, source, destination, 0) |
| 14 | + ({...model, videoCoordination: {...newState, loading: true}}, Tea_Cmd.none) |
| 15 | + | PauseTransfer(_batchId) => (model, Tea_Cmd.none) |
| 16 | + | RefreshStatus => ({...model, videoCoordination: {...vc, loading: true}}, Tea_Cmd.none) |
| 17 | + | StatusResult(Ok(_json)) => ({...model, videoCoordination: {...vc, loading: false}}, Tea_Cmd.none) |
| 18 | + | StatusResult(Error(err)) => ( |
| 19 | + {...model, videoCoordination: {...vc, loading: false, error: Some(err)}}, |
| 20 | + Tea_Cmd.none, |
| 21 | + ) |
| 22 | + | TransferResult(Ok(_json)) => ( |
| 23 | + {...model, videoCoordination: {...vc, loading: false}}, |
| 24 | + Tea_Cmd.none, |
| 25 | + ) |
| 26 | + | TransferResult(Error(err)) => ( |
| 27 | + {...model, videoCoordination: {...vc, loading: false, error: Some(err)}}, |
| 28 | + Tea_Cmd.none, |
| 29 | + ) |
| 30 | + | ClearError => ({...model, videoCoordination: {...vc, error: None}}, Tea_Cmd.none) |
| 31 | + } |
| 32 | +} |
0 commit comments