diff --git a/client/src/javascript/components/general/ListViewport.tsx b/client/src/javascript/components/general/ListViewport.tsx index 703615d8..19ed8ac3 100644 --- a/client/src/javascript/components/general/ListViewport.tsx +++ b/client/src/javascript/components/general/ListViewport.tsx @@ -249,7 +249,7 @@ class ListViewport extends React.Component { this.topSpacerRef = ref; - if (itemHeight == null && this.topSpacerRef != null && this.topSpacerRef.nextSibling != null) { + if (itemHeight == null && this.topSpacerRef?.nextSibling != null) { this.setState({ itemHeight: (this.topSpacerRef.nextSibling as HTMLLIElement).offsetHeight, }); diff --git a/client/src/javascript/components/modals/add-torrents-modal/AddTorrentsByFile.tsx b/client/src/javascript/components/modals/add-torrents-modal/AddTorrentsByFile.tsx index daa39b76..24166ca3 100644 --- a/client/src/javascript/components/modals/add-torrents-modal/AddTorrentsByFile.tsx +++ b/client/src/javascript/components/modals/add-torrents-modal/AddTorrentsByFile.tsx @@ -106,7 +106,7 @@ class AddTorrentsByFile extends React.Component { this.setState((state) => { - if (e.target != null && e.target.result != null && typeof e.target.result === 'string') { + if (e.target?.result != null && typeof e.target.result === 'string') { return { errors: nextErrorsState, files: state.files.concat({ diff --git a/client/src/javascript/components/modals/feeds-modal/DownloadRulesTab.tsx b/client/src/javascript/components/modals/feeds-modal/DownloadRulesTab.tsx index 03d2fc4a..13dca949 100644 --- a/client/src/javascript/components/modals/feeds-modal/DownloadRulesTab.tsx +++ b/client/src/javascript/components/modals/feeds-modal/DownloadRulesTab.tsx @@ -488,7 +488,7 @@ class DownloadRulesTab extends React.Component { const errorID = error as ValidatedFields; - if (this.state.errors == null || this.state.errors[errorID] == null) { + if (this.state.errors?.[errorID] == null) { return null; } return ( diff --git a/client/src/javascript/components/modals/feeds-modal/FeedsTab.tsx b/client/src/javascript/components/modals/feeds-modal/FeedsTab.tsx index 3330ec98..2f8175b6 100644 --- a/client/src/javascript/components/modals/feeds-modal/FeedsTab.tsx +++ b/client/src/javascript/components/modals/feeds-modal/FeedsTab.tsx @@ -426,7 +426,7 @@ class FeedsTab extends React.Component { if (formData != null) { if (currentFeed === defaultFeed) { FeedsStoreClass.addFeed(formData); - } else if (currentFeed != null && currentFeed._id != null) { + } else if (currentFeed?._id != null) { FeedsStoreClass.modifyFeed(currentFeed._id, formData); } } @@ -550,7 +550,7 @@ class FeedsTab extends React.Component { if (this.state.errors != null) { errors = Object.keys(this.state.errors).map((error) => { const errorID = error as ValidatedFields; - if (this.state.errors == null || this.state.errors[errorID] == null) { + if (this.state.errors?.[errorID] == null) { return null; } return ( diff --git a/client/src/javascript/components/sidebar/TransferRateDetails.tsx b/client/src/javascript/components/sidebar/TransferRateDetails.tsx index ca0aace2..dcd19e50 100644 --- a/client/src/javascript/components/sidebar/TransferRateDetails.tsx +++ b/client/src/javascript/components/sidebar/TransferRateDetails.tsx @@ -70,7 +70,7 @@ class TransferRateDetails extends React.Component { 'is-visible': inspectorPoint != null && options.showHoverDuration, }); - if (inspectorPoint != null && inspectorPoint.nearestTimestamp != null) { + if (inspectorPoint?.nearestTimestamp != null) { const currentTime = dayjs(Date.now()); const durationSummary = formatUtil.secondsToDuration( dayjs.duration(currentTime.diff(dayjs(inspectorPoint.nearestTimestamp))).asSeconds(), diff --git a/client/src/javascript/components/torrent-list/TorrentList.tsx b/client/src/javascript/components/torrent-list/TorrentList.tsx index 27291ed9..5f6fed08 100644 --- a/client/src/javascript/components/torrent-list/TorrentList.tsx +++ b/client/src/javascript/components/torrent-list/TorrentList.tsx @@ -214,7 +214,7 @@ class TorrentList extends React.Component { files.forEach((file) => { const reader = new FileReader(); reader.onload = (e) => { - if (e.target != null && e.target.result != null && typeof e.target.result === 'string') { + if (e.target?.result != null && typeof e.target.result === 'string') { callback(e.target.result.split('base64,')[1]); } }; diff --git a/client/src/javascript/ui/components/Select.tsx b/client/src/javascript/ui/components/Select.tsx index 91883518..12569b47 100644 --- a/client/src/javascript/ui/components/Select.tsx +++ b/client/src/javascript/ui/components/Select.tsx @@ -97,7 +97,7 @@ export default class Select extends Component { return (child as SelectItem).props.id != null; }) as SelectItem; - if (item != null && item.props.id != null) { + if (item?.props?.id != null) { return item.props.id; } } diff --git a/client/src/javascript/util/selectionTree.ts b/client/src/javascript/util/selectionTree.ts index ba4c6394..1dd31592 100644 --- a/client/src/javascript/util/selectionTree.ts +++ b/client/src/javascript/util/selectionTree.ts @@ -48,7 +48,7 @@ const applySelection = ( // Change happens if (recursiveDepth === depth - 1) { - if (type === 'file' && tree.files != null && tree.files[currentPath] != null) { + if (type === 'file' && tree.files?.[currentPath] != null) { const files = { ...tree.files, [currentPath]: { diff --git a/server/models/Users.ts b/server/models/Users.ts index aa0623b8..f4943d9c 100644 --- a/server/models/Users.ts +++ b/server/models/Users.ts @@ -55,7 +55,7 @@ class Users { } // Wrong data provided - if (credentials == null || credentials.password == null) { + if (credentials?.password == null) { return callback(false, null, new Error()); } @@ -120,7 +120,7 @@ class Users { } // Username not found. - if (user == null || user._id == null) { + if (user?._id == null) { return callback(null, new Error('User not found.')); } diff --git a/server/services/taxonomyService.ts b/server/services/taxonomyService.ts index 516e5c08..719e857c 100644 --- a/server/services/taxonomyService.ts +++ b/server/services/taxonomyService.ts @@ -28,7 +28,7 @@ class TaxonomyService extends BaseService { this.handleProcessTorrentListEnd = this.handleProcessTorrentListEnd.bind(this); this.onServicesUpdated = () => { - if (this.services == null || this.services.clientGatewayService == null) { + if (this.services?.clientGatewayService == null) { return; } @@ -41,7 +41,7 @@ class TaxonomyService extends BaseService { } destroy() { - if (this.services == null || this.services.clientGatewayService == null) { + if (this.services?.clientGatewayService == null) { return; } diff --git a/server/services/torrentService.ts b/server/services/torrentService.ts index 3deec0bf..036d7c7b 100644 --- a/server/services/torrentService.ts +++ b/server/services/torrentService.ts @@ -29,7 +29,7 @@ class TorrentService extends BaseService { this.handleFetchTorrentListError = this.handleFetchTorrentListError.bind(this); this.onServicesUpdated = () => { - if (this.services == null || this.services.clientGatewayService == null) { + if (this.services?.clientGatewayService == null) { return; }