Skip to content

Commit 4d686bf

Browse files
committed
fix linting issues
1 parent a04f7fa commit 4d686bf

File tree

5 files changed

+27
-28
lines changed

5 files changed

+27
-28
lines changed

client/src/javascript/components/modals/chromecast-modal/ChromecastModal.tsx

Lines changed: 19 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -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>

client/src/javascript/util/chromecastUtil.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import {chromecastableExtensions, subtitleExtensions} from '../../../../shared/c
22

33
export function isFileChromecastable(filename: string): boolean {
44
const fileExtension = filename.split('.').pop();
5+
if (!fileExtension) return false;
56
return fileExtension in chromecastableExtensions;
67
}
78

@@ -12,5 +13,6 @@ export function getChromecastContentType(filename: string): string | undefined {
1213

1314
export function isFileSubtitles(filename: string): boolean {
1415
const fileExtension = filename.split('.').pop();
16+
if (!fileExtension) return false;
1517
return subtitleExtensions.includes(fileExtension);
1618
}

server/routes/api/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import type {FloodSettings} from '@shared/types/FloodSettings';
1010
import type {HistorySnapshot} from '@shared/constants/historySnapshotTypes';
1111
import type {NotificationFetchOptions} from '@shared/types/Notification';
1212
import type {SetFloodSettingsOptions} from '@shared/types/api/index';
13+
import type {RequestHandler} from 'express';
1314

1415
import {accessDeniedError, isAllowedPath, sanitizePath} from '../../util/fileUtil';
1516
import appendUserServices from '../../middleware/appendUserServices';
@@ -27,7 +28,7 @@ router.use('/auth', authRoutes);
2728

2829
// Special routes that may bypass authentication when conditions matched
2930

30-
const authenticateContentRequest = async (req, _res, next) => {
31+
const authenticateContentRequest: RequestHandler = async (req, _res, next) => {
3132
const {token} = req.query;
3233

3334
if (typeof token === 'string' && token !== '') {

server/routes/api/torrents.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -927,16 +927,16 @@ router.get(
927927
return;
928928
}
929929

930-
let index = stringIndex ? Number(stringIndex) : contents[0].index;
930+
const index = stringIndex ? Number(stringIndex) : contents[0].index;
931931

932-
let subtitleSourceContent = contents.find((content) => index == content.index);
932+
const subtitleSourceContent = contents.find((content) => index == content.index);
933933

934934
if (!subtitleSourceContent) {
935935
res.status(404).json({error: 'Torrent contents not found'});
936936
return;
937937
}
938938

939-
let subtitleSourcePath = sanitizePath(path.join(selectedTorrent.directory, subtitleSourceContent.path));
939+
const subtitleSourcePath = sanitizePath(path.join(selectedTorrent.directory, subtitleSourceContent.path));
940940

941941
if (!isAllowedPath(subtitleSourcePath)) {
942942
const {code, message} = accessDeniedError();

server/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"paths": {
1414
"@shared/*": ["shared/*"]
1515
},
16-
"outDir": "../dist"
16+
"outDir": "../dist",
1717
},
1818
"include": ["./**/*.ts", "../shared/**/*.ts", "../config.js", "../config.ts"]
1919
}

0 commit comments

Comments
 (0)