From 66216bd5b678cd8d1107262a25bccf30be0fcf32 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?marcin=20miko=C5=82ajczak?= Date: Fri, 12 Aug 2022 13:47:32 +0200 Subject: [PATCH] Use Array.includes instead of indexOf MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: marcin mikołajczak --- app/soapbox/base_polyfills.ts | 2 +- app/soapbox/components/autosuggest_input.tsx | 2 +- .../components/autosuggest_textarea.tsx | 2 +- .../account_gallery/components/media_item.js | Bin 5060 -> 5048 bytes .../features/emoji/emoji_mart_search_light.js | Bin 4634 -> 4618 bytes app/soapbox/features/emoji/emoji_utils.js | Bin 6046 -> 6032 bytes .../features/status/components/card.tsx | 2 +- .../features/ui/components/modal_root.js | Bin 3122 -> 3117 bytes .../features/ui/components/user_panel.tsx | 2 +- app/soapbox/features/ui/index.tsx | 2 +- app/soapbox/selectors/index.ts | 2 +- 11 files changed, 7 insertions(+), 7 deletions(-) diff --git a/app/soapbox/base_polyfills.ts b/app/soapbox/base_polyfills.ts index 53146d222b..a6e92bb3c0 100644 --- a/app/soapbox/base_polyfills.ts +++ b/app/soapbox/base_polyfills.ts @@ -37,7 +37,7 @@ if (!HTMLCanvasElement.prototype.toBlob) { const dataURL = this.toDataURL(type, quality); let data; - if (dataURL.indexOf(BASE64_MARKER) >= 0) { + if (dataURL.includes(BASE64_MARKER)) { const [, base64] = dataURL.split(BASE64_MARKER); data = decodeBase64(base64); } else { diff --git a/app/soapbox/components/autosuggest_input.tsx b/app/soapbox/components/autosuggest_input.tsx index e6a4af6d6d..54f126a233 100644 --- a/app/soapbox/components/autosuggest_input.tsx +++ b/app/soapbox/components/autosuggest_input.tsx @@ -30,7 +30,7 @@ const textAtCursorMatchesToken = (str: string, caretPosition: number, searchToke word = str.slice(left, right + caretPosition); } - if (!word || word.trim().length < 3 || searchTokens.indexOf(word[0]) === -1) { + if (!word || word.trim().length < 3 || !searchTokens.includes(word[0])) { return [null, null]; } diff --git a/app/soapbox/components/autosuggest_textarea.tsx b/app/soapbox/components/autosuggest_textarea.tsx index b5d54b6700..a475e5ce21 100644 --- a/app/soapbox/components/autosuggest_textarea.tsx +++ b/app/soapbox/components/autosuggest_textarea.tsx @@ -23,7 +23,7 @@ const textAtCursorMatchesToken = (str: string, caretPosition: number) => { word = str.slice(left, right + caretPosition); } - if (!word || word.trim().length < 3 || ['@', ':', '#'].indexOf(word[0]) === -1) { + if (!word || word.trim().length < 3 || !['@', ':', '#'].includes(word[0])) { return [null, null]; } diff --git a/app/soapbox/features/account_gallery/components/media_item.js b/app/soapbox/features/account_gallery/components/media_item.js index fe8c6cc85a64a7491fc33602109946fc45af81e4..aa15e39e2d8686b98be8fd3832b1cca79d1bcb95 100644 GIT binary patch delta 52 zcmX@2zC(S3IU9R&PH9SNvBqQr7D-MG^^(ehRCP_w&1r0RSlA#^lN~w58G$0)aU1}@ COArSD delta 82 zcmdm?enfqPIU8F_YK4EA#$*E)NdXP@lFEWqbxlnLMO#}1UBk@@Y delta 101 zcmeBDnWeHJmxDDWwZcDb@&gVz7CQx9!^smkywHR;|K;Fk6ag#KP){x`F3HbT*HnNi R7N2a)Wr) diff --git a/app/soapbox/features/emoji/emoji_utils.js b/app/soapbox/features/emoji/emoji_utils.js index 1f4629edf92efe1a061545dd0a1685eb07a835f6..ad03195985a16df67c340809bdce21135a8c4981 100644 GIT binary patch delta 74 zcmbQIKS6)PBSvAx;?%^V}l++6UG>u|S1zTHN1zp3QyeM) diff --git a/app/soapbox/features/status/components/card.tsx b/app/soapbox/features/status/components/card.tsx index fbbe0648d9..d15eaadf3f 100644 --- a/app/soapbox/features/status/components/card.tsx +++ b/app/soapbox/features/status/components/card.tsx @@ -26,7 +26,7 @@ const addAutoPlay = (html: string): string => { const iframe = document.querySelector('iframe'); if (iframe) { - if (iframe.src.indexOf('?') !== -1) { + if (iframe.src.includes('?')) { iframe.src += '&'; } else { iframe.src += '?'; diff --git a/app/soapbox/features/ui/components/modal_root.js b/app/soapbox/features/ui/components/modal_root.js index 62f9fa50f09e4c29f975db971b4fd99d53066705..f7b9b007cc8ca69c72f900ab905874e1fcb0701e 100644 GIT binary patch delta 34 pcmdlau~uS(0w<&5WCczW{^Xp}l+k03$OqH diff --git a/app/soapbox/features/ui/components/user_panel.tsx b/app/soapbox/features/ui/components/user_panel.tsx index 6bf77b6598..3c801fd255 100644 --- a/app/soapbox/features/ui/components/user_panel.tsx +++ b/app/soapbox/features/ui/components/user_panel.tsx @@ -28,7 +28,7 @@ const UserPanel: React.FC = ({ accountId, action, badges, domain }) if (!account) return null; const displayNameHtml = { __html: account.get('display_name_html') }; - const acct = account.get('acct').indexOf('@') === -1 && domain ? `${account.get('acct')}@${domain}` : account.get('acct'); + const acct = !account.get('acct').includes('@') && domain ? `${account.get('acct')}@${domain}` : account.get('acct'); const header = account.get('header'); const verified = account.get('verified'); diff --git a/app/soapbox/features/ui/index.tsx b/app/soapbox/features/ui/index.tsx index b9fdab67d6..e7c0f74e2c 100644 --- a/app/soapbox/features/ui/index.tsx +++ b/app/soapbox/features/ui/index.tsx @@ -352,7 +352,7 @@ const UI: React.FC = ({ children }) => { const handleDragEnter = (e: DragEvent) => { e.preventDefault(); - if (e.target && dragTargets.current.indexOf(e.target) === -1) { + if (e.target && !dragTargets.current.includes(e.target)) { dragTargets.current.push(e.target); } diff --git a/app/soapbox/selectors/index.ts b/app/soapbox/selectors/index.ts index c1ab55532b..2a026afe15 100644 --- a/app/soapbox/selectors/index.ts +++ b/app/soapbox/selectors/index.ts @@ -93,7 +93,7 @@ const toServerSideType = (columnType: string): string => { case 'thread': return columnType; default: - if (columnType.indexOf('list:') > -1) { + if (columnType.includes('list:')) { return 'home'; } else { return 'public'; // community, account, hashtag