Skip to content

Commit

Permalink
Merge pull request #14101 from nextcloud/fix/noid/document-title-arch…
Browse files Browse the repository at this point in the history
…ived-conversation

fix(useDocumentTitle): skip asterik for normal messages in archives
DorraJaouad authored Jan 10, 2025
2 parents f441b4a + 40faaf4 commit 07ebe85
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/composables/useDocumentTitle.ts
Original file line number Diff line number Diff line change
@@ -4,7 +4,6 @@
*/

import { computed, ref, watch } from 'vue'
import type { ComputedRef } from 'vue'
import type { Route } from 'vue-router'

import { t } from '@nextcloud/l10n'
@@ -14,6 +13,7 @@ import { useStore } from './useStore.js'
import Router from '../router/router.js'
import { EventBus } from '../services/EventBus.ts'
import type { Conversation } from '../types/index.ts'
import { hasUnreadMentions, hasCall } from '../utils/conversation.js'

/**
* Composable to check whether the page is visible.
@@ -45,7 +45,7 @@ export function useDocumentTitle() {
const shouldShowAsterisk = Object.keys(newLastMessageMap).some(token => {
return savedLastMessageMap.value[token] === undefined // Conversation is new
|| (savedLastMessageMap.value[token] !== newLastMessageMap[token] // Last message changed
&& newLastMessageMap[token] !== -1) // But is not from the current user
&& newLastMessageMap[token] !== -1) // And it is not from the current user nor archived
})
if (shouldShowAsterisk) {
showAsterisk.value = true
@@ -89,15 +89,19 @@ export function useDocumentTitle() {
}

return conversationList.reduce((acc: Record<string, number>, conversation: Conversation) => {
const { token, lastMessage } = conversation
const { token, lastMessage, isArchived } = conversation
// Default to 0 for messages without valid lastMessage
if (!lastMessage || Array.isArray(lastMessage)) {
acc[token] = 0
return acc
}

if (lastMessage.actorId === actorId.value && lastMessage.actorType === actorType.value) {
// Set a special value when the actor is the author so we can skip it.
if ((lastMessage.actorId === actorId.value && lastMessage.actorType === actorType.value)
|| (isArchived && !hasUnreadMentions(conversation) && !hasCall(conversation))) {
// Set a special value when (one of the following is true):
// - The actor is the author
// - The conversation is archived and no relevant notification (mention or call).
// so to skip the asterisk for these messages
// Can't use 0 though because hidden commands result in 0,
// and they would hide other previously posted new messages
acc[token] = -1

0 comments on commit 07ebe85

Please sign in to comment.