@@ -25,32 +25,34 @@ TODO:
2525 refs ,
2626 s ,
2727 t ,
28- userSettings
28+ userSettings ,
29+ type PlayModeSettings
2930 } from ' $lib/data/stores' ;
3031 import { AudioIcon } from ' $lib/icons' ;
3132 import PlayButton from ' ./PlayButton.svelte' ;
3233 import RepeatButton from ' ./RepeatButton.svelte' ;
3334
34- function mayResetPlayMode(hasTiming ) {
35+ function mayResetPlayMode(hasTiming : boolean ) {
3536 // If the current mode is repeatSelection and the reference is changed to something without timing
3637 // (even chapter without audio), then reset the playMode. This matches how the Android app behaves.
3738 if (! hasTiming && $playMode .mode === ' repeatSelection' ) {
3839 playMode .reset ();
3940 }
4041 }
4142
42- function seekAudio(event ) {
43+ function seekAudio(event : MouseEvent ) {
4344 if (! $audioPlayer .loaded ) {
4445 return ;
4546 }
4647 const progressBar = document .getElementById (' progress-bar' );
47- const percent = (event .clientX - progressBar .offsetLeft ) / progressBar .offsetWidth ;
48+ const percent =
49+ (event .clientX - (progressBar ?.offsetLeft ?? 0 )) / (progressBar ?.offsetWidth ?? 1 );
4850 // Set the current time of the audio element to the corresponding time based on the percent
4951 seek ($audioPlayer .duration * percent );
5052 }
5153
5254 let lastPlayMode = ' ' ;
53- function playModeChanged(value ) {
55+ function playModeChanged(value : PlayModeSettings ) {
5456 let key = ' ' ;
5557
5658 switch (value .mode ) {
7779
7880 let hintText = $state (' ' );
7981 let showHint = $state (false );
80- let hintTimeoutId = null ;
81- function startShowHint(text ) {
82+ let hintTimeoutId: NodeJS . Timeout | null = null ;
83+ function startShowHint(text : string ) {
8284 showHint = true ;
8385 hintText = text ;
8486 if (hintTimeoutId ) {
@@ -92,14 +94,14 @@ TODO:
9294
9395 const showSpeed = config .mainFeatures [' settings-audio-speed' ];
9496 const showRepeatMode = config .mainFeatures [' audio-repeat-mode-button' ];
95- const hintStyle = convertStyle ($s [' ui.bar.audio.hint.text' ]);
97+ const hintStyle = convertStyle ($s ?. [' ui.bar.audio.hint.text' ]);
9698 const playButtonState = $derived ($audioPlayer .playing ? ' pause' : ' play' );
97- const iconColor = $derived ($s [' ui.bar.audio.icon' ][' color' ]);
98- const iconPlayColor = $derived ($s [' ui.bar.audio.play.icon' ][' color' ]);
99- const backgroundColor = $derived ($s [' ui.bar.audio' ][' background-color' ]);
99+ const iconColor = $derived ($s ?. [' ui.bar.audio.icon' ][' color' ]);
100+ const iconPlayColor = $derived ($s ?. [' ui.bar.audio.play.icon' ][' color' ]);
101+ const backgroundColor = $derived ($s ?. [' ui.bar.audio' ][' background-color' ]);
100102 const audioBarClass = $derived ($refs .hasAudio ?.timingFile ? ' audio-bar' : ' audio-bar-progress' );
101103 $effect (() => mayResetPlayMode ($refs .hasAudio ?.timing ));
102- $effect (() => updatePlaybackSpeed ($userSettings [' audio-speed' ]));
104+ $effect (() => updatePlaybackSpeed ($userSettings [' audio-speed' ] as string ));
103105 </script >
104106
105107<div class ="relative {audioBarClass }" style:background-color ={backgroundColor }>
0 commit comments