From 6e7de726866c70885828c27f0d16e47f1f6b7d94 Mon Sep 17 00:00:00 2001 From: jamesgeorge007 Date: Thu, 10 Oct 2019 10:53:42 +0530 Subject: [PATCH] feat: minor code refactor --- src/platforms/electron/index.js | 2 +- src/ui/component/fileViewerInitiator/view.jsx | 2 +- src/ui/component/wunderbar/internal/autocomplete.jsx | 4 ++-- src/ui/redux/actions/file.js | 2 +- src/ui/util/query-params.js | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/platforms/electron/index.js b/src/platforms/electron/index.js index de5278048..7daefcdad 100644 --- a/src/platforms/electron/index.js +++ b/src/platforms/electron/index.js @@ -133,7 +133,7 @@ if (!gotSingleInstanceLock) { // HACK: patch webrequest to fix devtools incompatibility with electron 2.x. // See https://github.com/electron/electron/issues/13008#issuecomment-400261941 session.defaultSession.webRequest.onBeforeRequest({}, (details, callback) => { - if (details.url.indexOf('7accc8730b0f99b5e7c0702ea89d1fa7c17bfe33') !== -1) { + if (details.url.includes('7accc8730b0f99b5e7c0702ea89d1fa7c17bfe33')) { callback({ redirectURL: details.url.replace( '7accc8730b0f99b5e7c0702ea89d1fa7c17bfe33', diff --git a/src/ui/component/fileViewerInitiator/view.jsx b/src/ui/component/fileViewerInitiator/view.jsx index f980983dc..c61c3d155 100644 --- a/src/ui/component/fileViewerInitiator/view.jsx +++ b/src/ui/component/fileViewerInitiator/view.jsx @@ -43,7 +43,7 @@ export default function FileViewer(props: Props) { costInfo, } = props; const cost = costInfo && costInfo.cost; - const isPlayable = ['audio', 'video'].indexOf(mediaType) !== -1; + const isPlayable = ['audio', 'video'].includes(mediaType); const fileStatus = fileInfo && fileInfo.status; const supported = (IS_WEB && isStreamable) || !IS_WEB; diff --git a/src/ui/component/wunderbar/internal/autocomplete.jsx b/src/ui/component/wunderbar/internal/autocomplete.jsx index 7c1f0d378..5e3ae242d 100644 --- a/src/ui/component/wunderbar/internal/autocomplete.jsx +++ b/src/ui/component/wunderbar/internal/autocomplete.jsx @@ -371,10 +371,10 @@ export default class Autocomplete extends React.Component { if (value !== '' && matchedItem) { const itemValue = getItemValue(matchedItem); const itemValueDoesMatch = - itemValue.toLowerCase().indexOf( + itemValue.toLowerCase().includes( value.toLowerCase() // below line is the the only thing that is changed from the real component - ) !== -1; + ); if (itemValueDoesMatch) { return { highlightedIndex: index }; } diff --git a/src/ui/redux/actions/file.js b/src/ui/redux/actions/file.js index 2842b16ac..189e6a0a5 100644 --- a/src/ui/redux/actions/file.js +++ b/src/ui/redux/actions/file.js @@ -41,7 +41,7 @@ export function doDeleteFile(outpoint, deleteFromComputer, abandonClaim) { // If the file is for a claim we published then also abandon the claim const myClaimsOutpoints = selectMyClaimsOutpoints(state); - if (abandonClaim && myClaimsOutpoints.indexOf(outpoint) !== -1) { + if (abandonClaim && myClaimsOutpoints.includes(outpoint)) { const [txid, nout] = outpoint.split(':'); dispatch(doAbandonClaim(txid, Number(nout))); diff --git a/src/ui/util/query-params.js b/src/ui/util/query-params.js index e14b0282b..80f1c5fc2 100644 --- a/src/ui/util/query-params.js +++ b/src/ui/util/query-params.js @@ -30,7 +30,7 @@ export function toQueryString(params) { // https://stackoverflow.com/questions/5999118/how-can-i-add-or-update-a-query-string-parameter export function updateQueryParam(uri, key, value) { const re = new RegExp('([?&])' + key + '=.*?(&|$)', 'i'); - const separator = uri.indexOf('?') !== -1 ? '&' : '?'; + const separator = uri.includes('?') ? '&' : '?'; if (uri.match(re)) { return uri.replace(re, '$1' + key + '=' + value + '$2'); } else {