diff --git a/src/components/LeftSidebar/LeftSidebar.vue b/src/components/LeftSidebar/LeftSidebar.vue
index f7c54e11bb2d..fbd8a68f7716 100644
--- a/src/components/LeftSidebar/LeftSidebar.vue
+++ b/src/components/LeftSidebar/LeftSidebar.vue
@@ -121,16 +121,29 @@
- -
+
+
+
+
+
+
+
+
+
+
+ {{ 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) {
+ let validConversationsCount = 0
+ const filteredConversations = this.conversationsList.filter((conversation) => {
+ const conversationIsValid = filterFunction(this.isFiltered, conversation)
+ if (conversationIsValid) {
+ validConversationsCount++
+ }
+ return conversationIsValid
+ || conversation.hasCall
+ || conversation.token === this.token
+ })
+ // return empty if it only includes the current conversation without any flags
+ return validConversationsCount === 0 && !this.isNavigating ? [] : filteredConversations
}
return this.conversationsList
@@ -449,6 +486,14 @@ export default {
},
},
+ watch: {
+ token(value) {
+ if (value && this.isFiltered) {
+ this.isNavigating = true
+ }
+ },
+ },
+
beforeMount() {
// Restore last fetched conversations from browser storage,
// before updated ones come from server
@@ -524,16 +569,16 @@ export default {
handleFilter(filter) {
this.isFiltered = filter
-
// Store the active filter
if (filter) {
BrowserStorage.setItem('filterEnabled', filter)
} else {
BrowserStorage.removeItem('filterEnabled')
}
-
// Clear the search input once a filter is active
this.searchText = ''
+ // Initiate the navigation status
+ this.isNavigating = false
},
scrollBottomUnread() {
@@ -926,6 +971,11 @@ export default {
}
+:deep(.empty-content) {
+ text-align: center;
+ padding: 20% 10px 0;
+}
+
.settings-button {
justify-content: flex-start !important;
}
diff --git a/src/store/conversationsStore.js b/src/store/conversationsStore.js
index 62bbee38184a..278461d57c9c 100644
--- a/src/store/conversationsStore.js
+++ b/src/store/conversationsStore.js
@@ -580,7 +580,7 @@ const actions = {
return
}
- commit('updateUnreadMessages', { token, unreadMessages: 0, unreadMention: false })
+ commit('updateUnreadMessages', { token, unreadMessages: 0, unreadMention: false, unreadMentionDirect: false })
},
async markConversationUnread({ commit, dispatch, getters }, { token }) {
diff --git a/src/utils/conversation.js b/src/utils/conversation.js
new file mode 100644
index 000000000000..b2e62b63d9fa
--- /dev/null
+++ b/src/utils/conversation.js
@@ -0,0 +1,59 @@
+/**
+ * @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))
+}
+
+/**
+ * apply the active filter
+ *
+ * @param {string} filter the filter option
+ * @param {object} conversation conversation object
+ */
+export function filterFunction(filter, conversation) {
+ if (filter === 'unread') {
+ return hasUnreadMessages(conversation)
+ } else if (filter === 'mentions') {
+ return hasUnreadMentions(conversation)
+ }
+}