diff --git a/src/components/LeftSidebar/LeftSidebar.vue b/src/components/LeftSidebar/LeftSidebar.vue
index 6404c612d530..38049f0d92fd 100644
--- a/src/components/LeftSidebar/LeftSidebar.vue
+++ b/src/components/LeftSidebar/LeftSidebar.vue
@@ -121,7 +121,22 @@
-
+
+
+
+
+
+
+
+
+
+
+ {{ t('spreed', 'Clear filter') }}
+
+
+
-
conversation.unreadMessages > 0
- || conversation.hasCall || conversation.token === this.$store.getters.getToken())
- }
-
- if (this.isFiltered === 'mentions') {
- return this.conversationsList.filter(conversation => conversation.unreadMention
- || conversation.hasCall
- || (conversation.unreadMessages > 0 && (conversation.type === CONVERSATION.TYPE.ONE_TO_ONE || conversation.type === CONVERSATION.TYPE.ONE_TO_ONE_FORMER))
- || conversation.token === this.$store.getters.getToken())
+ // applying filters
+ if (this.isFiltered) {
+ const filteredConversations = this.conversationsList.filter(function(conversation) {
+ return this.filterFunction(conversation)
+ || conversation.hasCall
+ || conversation.token === this.token
+ }.bind(this))
+
+ // return empty if it only includes the current conversation without any flags
+ const includesCurrentConversationOnly = filteredConversations.length === 1
+ && filteredConversations.filter(function(conversation) {
+ return !this.filterFunction(conversation) && conversation.token === this.token
+ }.bind(this)).length
+
+ return includesCurrentConversationOnly ? [] : filteredConversations
}
return this.conversationsList
@@ -537,6 +575,14 @@ export default {
this.searchText = ''
},
+ filterFunction(conversation) {
+ if (this.isFiltered === 'unread') {
+ return hasUnreadMessages(conversation)
+ } else if (this.isFiltered === 'mentions') {
+ return hasUnreadMentions(conversation)
+ }
+ },
+
scrollBottomUnread() {
this.preventFindingUnread = true
this.$refs.scroller.scrollToItem(this.lastUnreadMentionBelowViewportIndex)
@@ -927,6 +973,11 @@ export default {
}
+:deep(.empty-content) {
+ text-align: center;
+ margin-top: 10%;
+}
+
.settings-button {
justify-content: flex-start !important;
}
diff --git a/src/utils/conversation.js b/src/utils/conversation.js
new file mode 100644
index 000000000000..9911b225e69f
--- /dev/null
+++ b/src/utils/conversation.js
@@ -0,0 +1,47 @@
+/**
+ * @copyright Copyright (c) 2023
+ *
+ * @author Dorra Jaouad
+ *
+ * @license AGPL-3.0-or-later
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ *
+ */
+import {
+ CONVERSATION,
+} from '../constants.js'
+
+/**
+ * check if the conversation has unread messages
+ *
+ * @param {object} conversation conversation object
+ * @return {boolean}
+ */
+export function hasUnreadMessages(conversation) {
+ return conversation.unreadMessages > 0
+}
+
+/**
+ * check if the conversation has unread mentions
+ *
+ * @param {object} conversation conversation object
+ * @return {boolean}
+ */
+export function hasUnreadMentions(conversation) {
+ return conversation.unreadMention
+ || conversation.unreadMentionDirect
+ || (conversation.unreadMessages > 0
+ && (conversation.type === CONVERSATION.TYPE.ONE_TO_ONE || conversation.type === CONVERSATION.TYPE.ONE_TO_ONE_FORMER))
+}