From afee01602f423085f02d5cbc7e0e764a0ebcda8c Mon Sep 17 00:00:00 2001 From: Yasin Silavi Date: Wed, 24 May 2023 23:03:48 +0330 Subject: [PATCH] Fix some more code smells --- src/apps/stable/routes/user/userparentalcontrol.tsx | 2 +- src/apps/stable/routes/user/userprofile.tsx | 2 +- src/components/ServerContentPage.tsx | 2 +- src/components/alphaPicker/alphaPicker.js | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/apps/stable/routes/user/userparentalcontrol.tsx b/src/apps/stable/routes/user/userparentalcontrol.tsx index bee0fde1c7..691d8ed5e4 100644 --- a/src/apps/stable/routes/user/userparentalcontrol.tsx +++ b/src/apps/stable/routes/user/userparentalcontrol.tsx @@ -143,7 +143,7 @@ const UserParentalControl: FunctionComponent = () => { for (const btnDelete of accessScheduleList.querySelectorAll('.btnDelete')) { btnDelete.addEventListener('click', function () { - const index = parseInt(btnDelete.getAttribute('data-index') || '0', 10); + const index = parseInt(btnDelete.getAttribute('data-index') ?? '0', 10); schedules.splice(index, 1); const newindex = schedules.filter(function (i: number) { return i != index; diff --git a/src/apps/stable/routes/user/userprofile.tsx b/src/apps/stable/routes/user/userprofile.tsx index 0c038bc84a..04b31785b4 100644 --- a/src/apps/stable/routes/user/userprofile.tsx +++ b/src/apps/stable/routes/user/userprofile.tsx @@ -102,7 +102,7 @@ const UserProfile: FunctionComponent = () => { const target = evt.target as HTMLInputElement; const file = (target.files as FileList)[0]; - if (!file || !file.type.match('image.*')) { + if (!/image.*/.exec(file?.type)) { return false; } diff --git a/src/components/ServerContentPage.tsx b/src/components/ServerContentPage.tsx index 5b86d66072..c808b7216e 100644 --- a/src/components/ServerContentPage.tsx +++ b/src/components/ServerContentPage.tsx @@ -31,7 +31,7 @@ const ServerContentPage: FunctionComponent = ({ view }) viewManager.tryRestoreView(viewOptions) .catch(async (result?: RestoreViewFailResponse) => { - if (!result || !result.cancelled) { + if (!result?.cancelled) { const apiClient = ServerConnections.currentApiClient(); // Fetch the view html from the server and translate it diff --git a/src/components/alphaPicker/alphaPicker.js b/src/components/alphaPicker/alphaPicker.js index dd97c59074..a90e9a08a6 100644 --- a/src/components/alphaPicker/alphaPicker.js +++ b/src/components/alphaPicker/alphaPicker.js @@ -179,7 +179,7 @@ export class AlphaPicker { if (item) { const prefix = item.getAttribute('data-prefix'); - if (prefix && prefix.length) { + if (prefix?.length) { itemFocusValue = prefix[0]; if (itemFocusTimeout) { clearTimeout(itemFocusTimeout);