@@ -36,6 +36,10 @@ const GenerateMagnetModal: FC = () => {
3636 }
3737 } , [ ] ) ;
3838
39+ if ( UIStore . activeModal ?. id !== 'chromecast' ) {
40+ return null ;
41+ }
42+
3943 if ( ! initialized )
4044 return (
4145 < Modal
@@ -44,16 +48,15 @@ const GenerateMagnetModal: FC = () => {
4448 actions = { [
4549 {
4650 clickHandler : null ,
47- content : intl . formatMessage ( {
48- id : 'button.close' ,
49- } ) ,
51+ content : i18n . _ ( 'button.close' ) ,
5052 triggerDismiss : true ,
5153 type : 'tertiary' ,
5254 } ,
5355 ] }
5456 />
5557 ) ;
5658
59+ const hash = UIStore . activeModal ?. hash ;
5760 const mediaFiles = contents . filter ( ( file ) => isFileChromecastable ( file . filename ) ) ;
5861 const selectedFileName = ( contents [ selectedFileIndex ] ?. filename || '' ) . replace ( / \. \w + $ / , '' ) ;
5962 const subtitleSources : Subtitles [ ] = [
@@ -64,9 +67,8 @@ const GenerateMagnetModal: FC = () => {
6467 ] ;
6568
6669 const beginCasting = async ( ) => {
67- if ( ! UIStore . activeModal ?. hash || ! connected ) return ;
70+ if ( ! connected ) return ;
6871
69- const hash = UIStore . activeModal ?. hash ;
7072 const { filename} = contents [ selectedFileIndex ] ;
7173 const contentType = getChromecastContentType ( filename ) ;
7274 if ( ! contentType ) return ;
@@ -86,14 +88,14 @@ const GenerateMagnetModal: FC = () => {
8688 mediaInfo . textTrackStyle = new chrome . cast . media . TextTrackStyle ( ) ;
8789 mediaInfo . textTrackStyle . backgroundColor = '#00000000' ;
8890 mediaInfo . textTrackStyle . edgeColor = '#000000FF' ;
89- mediaInfo . textTrackStyle . edgeType = ' DROP_SHADOW' ;
91+ mediaInfo . textTrackStyle . edgeType = chrome . cast . media . TextTrackEdgeType . DROP_SHADOW ;
9092 mediaInfo . textTrackStyle . fontFamily = 'SANS_SERIF' ;
9193 mediaInfo . textTrackStyle . fontScale = 1.0 ;
9294 mediaInfo . textTrackStyle . foregroundColor = '#FFFFFF' ;
9395
94- const track = new chrome . cast . media . Track ( 0 , ' TEXT' ) ;
96+ const track = new chrome . cast . media . Track ( 0 , chrome . cast . media . TrackType . TEXT ) ;
9597 track . name = 'Text' ;
96- track . subtype = ' CAPTIONS' ;
98+ track . subtype = chrome . cast . media . TextTrackType . CAPTIONS ;
9799 track . trackContentId = await TorrentActions . getTorrentContentsSubtitlePermalink ( hash , selectedSubtitles ) ;
98100 track . trackContentType = 'text/vtt' ;
99101
@@ -111,23 +113,23 @@ const GenerateMagnetModal: FC = () => {
111113 const media = castSession . getMediaSession ( ) ;
112114 if ( ! media ) return ;
113115
114- media . stop ( new chrome . cast . media . StopRequest ( ) ) ;
116+ media . stop (
117+ new chrome . cast . media . StopRequest ( ) ,
118+ ( ) => { } ,
119+ ( ) => { } ,
120+ ) ;
115121 } ;
116122
117123 return (
118124 < Modal
119- heading = { intl . formatMessage ( {
120- id : 'chromecast.modal.title' ,
121- } ) }
125+ heading = { i18n . _ ( 'chromecast.modal.title' ) }
122126 content = {
123127 < div className = "modal__content inverse" >
124128 < Form >
125129 < FormRow >
126130 < Select
127131 id = "fileIndex"
128- label = { intl . formatMessage ( {
129- id : 'chromecast.modal.file' ,
130- } ) }
132+ label = { i18n . _ ( 'chromecast.modal.file' ) }
131133 onSelect = { ( fileIndex ) => {
132134 setSelectedFileIndex ( Number ( fileIndex ) ) ;
133135 setSelectedSubtitles ( 'none' ) ;
@@ -142,20 +144,14 @@ const GenerateMagnetModal: FC = () => {
142144 < FormRow >
143145 < Select
144146 id = "subtitleSource"
145- label = { intl . formatMessage ( {
146- id : 'chromecast.modal.subtitle' ,
147- } ) }
147+ label = { i18n . _ ( 'chromecast.modal.subtitle' ) }
148148 onSelect = { ( id ) => {
149149 if ( id === 'none' ) setSelectedSubtitles ( 'none' ) ;
150150 else setSelectedSubtitles ( Number ( id ) ) ;
151151 } } >
152152 { subtitleSources . map ( ( source ) => (
153153 < SelectItem key = { source } id = { `${ source } ` } >
154- { source === 'none'
155- ? intl . formatMessage ( {
156- id : 'chromecast.modal.subtitle.none' ,
157- } )
158- : contents [ source ] . filename }
154+ { source === 'none' ? i18n . _ ( 'chromecast.modal.subtitle.none' ) : contents [ source ] . filename }
159155 </ SelectItem >
160156 ) ) }
161157 </ Select >
0 commit comments