mirror of
https://github.com/zoriya/flood.git
synced 2026-06-01 10:35:59 +00:00
client, server: convert chained null checks to optional chaining
This commit is contained in:
@@ -249,7 +249,7 @@ class ListViewport extends React.Component<ListViewportProps, ListViewportStates
|
||||
ref={(ref) => {
|
||||
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,
|
||||
});
|
||||
|
||||
@@ -106,7 +106,7 @@ class AddTorrentsByFile extends React.Component<WrappedComponentProps, AddTorren
|
||||
const reader = new FileReader();
|
||||
reader.onload = (e) => {
|
||||
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({
|
||||
|
||||
@@ -488,7 +488,7 @@ class DownloadRulesTab extends React.Component<DownloadRulesTabProps, DownloadRu
|
||||
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 (
|
||||
|
||||
@@ -426,7 +426,7 @@ class FeedsTab extends React.Component<FeedsTabProps, FeedsTabStates> {
|
||||
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<FeedsTabProps, FeedsTabStates> {
|
||||
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 (
|
||||
|
||||
@@ -70,7 +70,7 @@ class TransferRateDetails extends React.Component<TransferRateDetailsProps> {
|
||||
'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(),
|
||||
|
||||
@@ -214,7 +214,7 @@ class TorrentList extends React.Component<TorrentListProps, TorrentListStates> {
|
||||
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]);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -97,7 +97,7 @@ export default class Select extends Component<SelectProps, SelectStates> {
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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]: {
|
||||
|
||||
@@ -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.'));
|
||||
}
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ class TaxonomyService extends BaseService<TaxonomyServiceEvents> {
|
||||
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<TaxonomyServiceEvents> {
|
||||
}
|
||||
|
||||
destroy() {
|
||||
if (this.services == null || this.services.clientGatewayService == null) {
|
||||
if (this.services?.clientGatewayService == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ class TorrentService extends BaseService<TorrentServiceEvents> {
|
||||
this.handleFetchTorrentListError = this.handleFetchTorrentListError.bind(this);
|
||||
|
||||
this.onServicesUpdated = () => {
|
||||
if (this.services == null || this.services.clientGatewayService == null) {
|
||||
if (this.services?.clientGatewayService == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user