diff options
author | Maksim Sukharev <antreesy.web@gmail.com> | 2023-04-01 13:52:26 +0200 |
---|---|---|
committer | Maksim Sukharev <antreesy.web@gmail.com> | 2023-04-05 16:14:19 +0200 |
commit | 9afe1ab64687065d3ef765f8e8aee84dff7e3ddd (patch) | |
tree | b230207a06d1a66a69f1249a4e8159aa6fb38db8 /src/components/LeftSidebar/LeftSidebar.vue | |
parent | 2dd0847edeaad997d19fb5e962ca7090edde1b98 (diff) |
adjust and refactor tests, improve readability
Signed-off-by: Maksim Sukharev <antreesy.web@gmail.com>
Diffstat (limited to 'src/components/LeftSidebar/LeftSidebar.vue')
-rw-r--r-- | src/components/LeftSidebar/LeftSidebar.vue | 52 |
1 files changed, 25 insertions, 27 deletions
diff --git a/src/components/LeftSidebar/LeftSidebar.vue b/src/components/LeftSidebar/LeftSidebar.vue index fb40ee151..bee212ba9 100644 --- a/src/components/LeftSidebar/LeftSidebar.vue +++ b/src/components/LeftSidebar/LeftSidebar.vue @@ -213,7 +213,10 @@ export default { if (this.searchText !== '') { const lowerSearchText = this.searchText.toLowerCase() - conversations = conversations.filter(conversation => conversation.displayName.toLowerCase().indexOf(lowerSearchText) !== -1 || conversation.name.toLowerCase().indexOf(lowerSearchText) !== -1) + conversations = conversations.filter(conversation => + conversation.displayName.toLowerCase().indexOf(lowerSearchText) !== -1 + || conversation.name.toLowerCase().indexOf(lowerSearchText) !== -1 + ) } // FIXME: this modifies the original array, @@ -236,41 +239,36 @@ export default { }, sourcesWithoutResultsList() { - if (!this.searchResultsUsers.length) { - if (!this.searchResultsGroups.length) { - if (this.isCirclesEnabled && !this.searchResultsCircles.length) { - return t('spreed', 'Users, groups and circles') - } else { - return t('spreed', 'Users and groups') - } + const hasNoResultsUsers = !this.searchResultsUsers.length + const hasNoResultsGroups = !this.searchResultsGroups.length + const hasNoResultsCircles = this.isCirclesEnabled && !this.searchResultsCircles.length + + if (hasNoResultsUsers) { + if (hasNoResultsGroups) { + return (hasNoResultsCircles) + ? t('spreed', 'Users, groups and circles') + : t('spreed', 'Users and groups') } else { - if (this.isCirclesEnabled && !this.searchResultsCircles.length) { - return t('spreed', 'Users and circles') - } else { - return t('spreed', 'Users') - } + return (hasNoResultsCircles) + ? t('spreed', 'Users and circles') + : t('spreed', 'Users') } } else { - if (!this.searchResultsGroups.length) { - if (this.isCirclesEnabled && !this.searchResultsCircles.length) { - return t('spreed', 'Groups and circles') - } else { - return t('spreed', 'Groups') - } + if (hasNoResultsGroups) { + return (hasNoResultsCircles) + ? t('spreed', 'Groups and circles') + : t('spreed', 'Groups') } else { - if (this.isCirclesEnabled && !this.searchResultsCircles.length) { - return t('spreed', 'Circles') - } + return (hasNoResultsCircles) + ? t('spreed', 'Circles') + : t('spreed', 'Other sources') } } - return t('spreed', 'Other sources') }, }, beforeMount() { - /** - * After a conversation was created, the search filter is reset - */ + // After a conversation was created, the search filter is reset EventBus.$once('resetSearchFilter', () => { this.abortSearch() }) @@ -279,7 +277,7 @@ export default { }, mounted() { - /** Refreshes the conversations every 30 seconds */ + // Refreshes the conversations every 30 seconds this.refreshTimer = window.setInterval(() => { if (!this.isFetchingConversations) { this.fetchConversations() |