From da17e4ee8a9c0c6f954a61fdab581a32fb887c1b Mon Sep 17 00:00:00 2001 From: nimbleghost <132819643+nimbleghost@users.noreply.github.com> Date: Wed, 24 May 2023 20:47:19 +0200 Subject: [PATCH] Make small code style improvements --- web/src/app/ConnectionManager.js | 4 +--- web/src/app/utils.js | 4 ++-- web/src/components/EmojiPicker.jsx | 12 +----------- 3 files changed, 4 insertions(+), 16 deletions(-) diff --git a/web/src/app/ConnectionManager.js b/web/src/app/ConnectionManager.js index 751c7bd3..2033cbea 100644 --- a/web/src/app/ConnectionManager.js +++ b/web/src/app/ConnectionManager.js @@ -61,9 +61,7 @@ class ConnectionManager { const { connectionId } = subscription; const added = !this.connections.get(connectionId); if (added) { - const { baseUrl } = subscription; - const { topic } = subscription; - const { user } = subscription; + const { baseUrl, topic, user } = subscription; const since = subscription.last; const connection = new Connection( connectionId, diff --git a/web/src/app/utils.js b/web/src/app/utils.js index 481d6031..ab7551bb 100644 --- a/web/src/app/utils.js +++ b/web/src/app/utils.js @@ -118,10 +118,10 @@ export const maybeWithBearerAuth = (headers, token) => { export const withBasicAuth = (headers, username, password) => ({ ...headers, Authorization: basicAuth(username, password) }); export const maybeWithAuth = (headers, user) => { - if (user && user.password) { + if (user?.password) { return withBasicAuth(headers, user.username, user.password); } - if (user && user.token) { + if (user?.token) { return withBearerAuth(headers, user.token); } return headers; diff --git a/web/src/components/EmojiPicker.jsx b/web/src/components/EmojiPicker.jsx index f9e8b5e8..d1fb1706 100644 --- a/web/src/components/EmojiPicker.jsx +++ b/web/src/components/EmojiPicker.jsx @@ -127,17 +127,7 @@ const Category = (props) => { ); }; -const emojiMatches = (emoji, words) => { - if (words.length === 0) { - return true; - } - for (const word of words) { - if (emoji.searchBase.indexOf(word) === -1) { - return false; - } - } - return true; -}; +const emojiMatches = (emoji, words) => words.length === 0 || words.some((word) => emoji.searchBase.includes(word)); const Emoji = (props) => { const { emoji } = props;