Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import { useStore } from 'vuex'
import NcActionButton from '@nextcloud/vue/components/NcActionButton'
import NcActionSeparator from '@nextcloud/vue/components/NcActionSeparator'
import NcAppNavigationItem from '@nextcloud/vue/components/NcAppNavigationItem'
import NcCounterBubble from '@nextcloud/vue/components/NcCounterBubble'
import NcIconSvgWrapper from '@nextcloud/vue/components/NcIconSvgWrapper'
import IconArrowDown from 'vue-material-design-icons/ArrowDown.vue'
import IconArrowUp from 'vue-material-design-icons/ArrowUp.vue'
Expand All @@ -26,8 +25,6 @@ import { useConversationTagsStore } from '../../../stores/conversationTags.ts'
export type TagHeaderItem = ConversationTag & {
_type: 'tag-header'
unreadCount: number
unreadMention: boolean
unreadMentionDirect: boolean
isFirst?: boolean
isLast?: boolean
}
Expand All @@ -40,15 +37,6 @@ const vuexStore = useStore()
const tagsStore = useConversationTagsStore()

const isCustomTag = computed(() => props.item.type === 'custom')
const counterType = computed(() => {
if (props.item.unreadMentionDirect) {
return 'highlighted'
} else if (props.item.unreadMention) {
return 'outlined'
} else {
return ''
}
})

/**
* Assign a new name to the tag via dialog
Expand Down Expand Up @@ -139,9 +127,6 @@ async function handleMarkReadTag() {
@update:open="tagsStore.toggleCollapsed(item.id)">
<!-- Invisible child to trigger the collapse chevron -->
<li class="tag-header__spacer" />
<template #counter>
<NcCounterBubble v-if="item.unreadCount > 0" :count="item.unreadCount" :type="counterType" />
</template>
<template #actions>
<NcActionButton
v-if="item.unreadCount > 0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { computed, watch } from 'vue'
import LoadingPlaceholder from '../../UIShared/LoadingPlaceholder.vue'
import ConversationItem from './ConversationItem.vue'
import ConversationTagHeader from './ConversationTagHeader.vue'
import { AVATAR, CONVERSATION } from '../../../constants.ts'
import { AVATAR } from '../../../constants.ts'
import { useConversationTagsStore } from '../../../stores/conversationTags.ts'
import { hasCall, hasUnreadMessages } from '../../../utils/conversation.ts'

Expand Down Expand Up @@ -56,34 +56,21 @@ const listItems = computed<VirtualListItem[]>(() => {
hasTagged: boolean
favorites: Conversation[]
favoritesUnreadCount: number
favoritesUnreadMention: boolean
favoritesUnreadMentionDirect: boolean
tagged: Record<string, Conversation[]>
taggedUnreadCount: Record<string, number>
taggedUnreadMention: Record<string, boolean>
taggedUnreadMentionDirect: Record<string, boolean>
other: Conversation[]
otherUnreadCount: number
otherUnreadMention: boolean
otherUnreadMentionDirect: boolean
}>((acc, conversation) => {
// Count amount of unread conversations, highlight if any has a direct or group mention
// Count amount of unread conversations
const unreadCount = conversation.unreadMessages ? 1 : 0
const unreadMention = conversation.unreadMention
const unreadMentionDirect = conversation.unreadMentionDirect
|| (!!unreadCount && [CONVERSATION.TYPE.ONE_TO_ONE, CONVERSATION.TYPE.ONE_TO_ONE_FORMER].includes(conversation.type))
const isTagged = !!conversation.tagIds?.length

if (conversation.isFavorite) {
acc.favorites.push(conversation)
acc.favoritesUnreadCount += unreadCount
acc.favoritesUnreadMention ||= unreadMention
acc.favoritesUnreadMentionDirect ||= unreadMentionDirect
} else if (!isTagged) {
acc.other.push(conversation)
acc.otherUnreadCount += unreadCount
acc.otherUnreadMention ||= unreadMention
acc.otherUnreadMentionDirect ||= unreadMentionDirect
}

if (isTagged) {
Expand All @@ -96,24 +83,16 @@ const listItems = computed<VirtualListItem[]>(() => {
acc.tagged[tagId] ??= []
acc.tagged[tagId].push(conversation)
acc.taggedUnreadCount[tagId] = (acc.taggedUnreadCount[tagId] || 0) + unreadCount
acc.taggedUnreadMention[tagId] = acc.taggedUnreadMention[tagId] || unreadMention
acc.taggedUnreadMentionDirect[tagId] = acc.taggedUnreadMentionDirect[tagId] || unreadMentionDirect
}
return acc
}, {
hasTagged: false,
favorites: [],
favoritesUnreadCount: 0,
favoritesUnreadMention: false,
favoritesUnreadMentionDirect: false,
tagged: {},
taggedUnreadCount: {},
taggedUnreadMention: {},
taggedUnreadMentionDirect: {},
other: [],
otherUnreadCount: 0,
otherUnreadMention: false,
otherUnreadMentionDirect: false,
})

if (!groupedConversations.hasTagged) {
Expand All @@ -124,8 +103,6 @@ const listItems = computed<VirtualListItem[]>(() => {
tag: ConversationTag
conversations: Conversation[]
unreadCount: number
unreadMention: boolean
unreadMentionDirect: boolean
}>>((acc, tag) => {
const conversations = tag.type === 'favorites'
? groupedConversations.favorites
Expand All @@ -142,23 +119,11 @@ const listItems = computed<VirtualListItem[]>(() => {
: tag.type === 'other'
? groupedConversations.otherUnreadCount
: (groupedConversations.taggedUnreadCount[tag.id] ?? 0)
const unreadMention = tag.type === 'favorites'
? groupedConversations.favoritesUnreadMention
: tag.type === 'other'
? groupedConversations.otherUnreadMention
: (groupedConversations.taggedUnreadMention[tag.id] ?? false)
const unreadMentionDirect = tag.type === 'favorites'
? groupedConversations.favoritesUnreadMentionDirect
: tag.type === 'other'
? groupedConversations.otherUnreadMentionDirect
: (groupedConversations.taggedUnreadMentionDirect[tag.id] ?? false)

acc.push({
tag,
conversations,
unreadCount,
unreadMention,
unreadMentionDirect,
})
return acc
}, [])
Expand All @@ -168,8 +133,6 @@ const listItems = computed<VirtualListItem[]>(() => {
...section.tag,
_type: 'tag-header',
unreadCount: section.unreadCount,
unreadMention: section.unreadMention,
unreadMentionDirect: section.unreadMentionDirect,
isFirst: index === 0,
isLast: index === renderedSections.length - 1,
}
Expand Down
Loading