diff options
author | Malte Voos <git@mal.tc> | 2025-10-07 20:57:48 +0200 |
---|---|---|
committer | Malte Voos <git@mal.tc> | 2025-10-07 20:57:48 +0200 |
commit | ee29a3b1291e9cedd8b54c31fa9f273e39f51970 (patch) | |
tree | e41665482ef2668e0313adc9701f03384152b208 /src/transcript.rs | |
parent | 8aa48d67b0908b62d012b589df9b35f2f8551968 (diff) | |
download | lleap-ee29a3b1291e9cedd8b54c31fa9f273e39f51970.tar.gz lleap-ee29a3b1291e9cedd8b54c31fa9f273e39f51970.zip |
revamp subtitle selection
Diffstat (limited to 'src/transcript.rs')
-rw-r--r-- | src/transcript.rs | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/src/transcript.rs b/src/transcript.rs index 2bddb72..eb3459d 100644 --- a/src/transcript.rs +++ b/src/transcript.rs @@ -50,7 +50,7 @@ pub struct Transcript { #[derive(Debug)] pub enum TranscriptMsg { NewCue(StreamIndex, SubtitleCue), - SelectTrack(StreamIndex), + SelectTrack(Option<StreamIndex>), ScrollToCue(usize), } @@ -116,14 +116,17 @@ impl SimpleComponent for Transcript { } } TranscriptMsg::SelectTrack(stream_index) => { - self.active_stream_index = Some(stream_index); + self.active_stream_index = stream_index; // Clear current widgets and populate with selected track's cues self.active_cues.guard().clear(); - let tracks = TRACKS.read(); - if let Some(track) = tracks.get(&stream_index) { - for cue in &track.cues { - self.active_cues.guard().push_back(cue.clone()); + + if let Some(stream_ix) = stream_index { + let tracks = TRACKS.read(); + if let Some(track) = tracks.get(&stream_ix) { + for cue in &track.cues { + self.active_cues.guard().push_back(cue.clone()); + } } } } |