mirror of
https://github.com/nextcloud/spreed.git
synced 2025-07-22 06:48:21 +00:00
fixup! fixup! fix: purge threads correctly
This commit is contained in:
@ -17,6 +17,7 @@ import NcDateTime from '@nextcloud/vue/components/NcDateTime'
|
||||
import NcListItem from '@nextcloud/vue/components/NcListItem'
|
||||
import IconArrowLeftTop from 'vue-material-design-icons/ArrowLeftTop.vue'
|
||||
import IconBellOutline from 'vue-material-design-icons/BellOutline.vue'
|
||||
import IconCommentAlertOutline from 'vue-material-design-icons/CommentAlertOutline.vue'
|
||||
import AvatarWrapper from '../../AvatarWrapper/AvatarWrapper.vue'
|
||||
import { getDisplayNameWithFallback } from '../../../utils/getDisplayName.ts'
|
||||
import { parseToSimpleMessage } from '../../../utils/textParse.ts'
|
||||
@ -26,9 +27,19 @@ const { thread } = defineProps<{ thread: ThreadInfo }>()
|
||||
const router = useRouter()
|
||||
const route = useRoute()
|
||||
|
||||
const threadAuthor = computed(() => getDisplayNameWithFallback(thread.first.actorDisplayName, thread.first.actorType, true))
|
||||
const threadAuthor = computed(() => {
|
||||
if (!thread.first) {
|
||||
return
|
||||
}
|
||||
return getDisplayNameWithFallback(thread.first.actorDisplayName, thread.first.actorType, true)
|
||||
})
|
||||
const lastActivity = computed(() => thread.thread.lastActivity * 1000)
|
||||
const name = computed(() => parseToSimpleMessage(thread.first.message, thread.first.messageParameters))
|
||||
const name = computed(() => {
|
||||
if (!thread.first) {
|
||||
return t('spreed', 'Thread origin message expired')
|
||||
}
|
||||
return parseToSimpleMessage(thread.first.message, thread.first.messageParameters)
|
||||
})
|
||||
const subname = computed(() => {
|
||||
if (!thread.last) {
|
||||
return t('spreed', 'No messages')
|
||||
@ -72,14 +83,22 @@ const timeFormat = computed<Intl.DateTimeFormatOptions>(() => {
|
||||
force-menu>
|
||||
<template #icon>
|
||||
<AvatarWrapper
|
||||
v-if="thread.first"
|
||||
:id="thread.first.actorId"
|
||||
:name="thread.first.actorDisplayName"
|
||||
:source="thread.first.actorType"
|
||||
disable-menu
|
||||
:token="thread.thread.roomToken" />
|
||||
<IconCommentAlertOutline
|
||||
v-else
|
||||
:size="20" />
|
||||
</template>
|
||||
<template #name>
|
||||
<span class="thread__author">{{ threadAuthor }}</span>
|
||||
<span
|
||||
v-if="threadAuthor"
|
||||
class="thread__author">
|
||||
{{ threadAuthor }}
|
||||
</span>
|
||||
<span>{{ name }}</span>
|
||||
</template>
|
||||
<template #subname>
|
||||
|
@ -1450,15 +1450,13 @@ const actions = {
|
||||
}
|
||||
const chatExtrasStore = useChatExtrasStore()
|
||||
const timestamp = convertToUnix(Date.now())
|
||||
const messageIds = Object.keys(context.state.messages[token])
|
||||
|
||||
messageIds.forEach((messageId) => {
|
||||
const message = context.state.messages[token][messageId]
|
||||
context.getters.messagesList(token).forEach((message) => {
|
||||
if (message.expirationTimestamp && timestamp > message.expirationTimestamp) {
|
||||
if (message.isThread) {
|
||||
chatExtrasStore.removeMessageFromThread(token, message.threadId, messageId)
|
||||
chatExtrasStore.removeMessageFromThread(token, message.threadId, message.id)
|
||||
}
|
||||
context.commit('deleteMessage', { token, id: messageId })
|
||||
context.commit('deleteMessage', { token, id: message.id })
|
||||
}
|
||||
})
|
||||
},
|
||||
|
@ -181,7 +181,7 @@ export const useChatExtrasStore = defineStore('chatExtras', {
|
||||
* Remove a thread from the store
|
||||
*
|
||||
* @param token - conversation token
|
||||
* @param threadId - thread id to remove
|
||||
* @param messageId - message id to remove all preceding threads (remove all, if omitted)
|
||||
*/
|
||||
clearThreads(token: string, messageId?: number) {
|
||||
if (messageId) {
|
||||
@ -211,11 +211,14 @@ export const useChatExtrasStore = defineStore('chatExtras', {
|
||||
|
||||
const thread = this.threads[token][threadId]
|
||||
if (thread.first.id === messageId) {
|
||||
// @ts-expect-error - missing null type in ThreadInfo
|
||||
thread.first = null
|
||||
} else {
|
||||
this.threads[token][threadId].thread.numReplies -= 1
|
||||
if (thread.last.id === messageId) {
|
||||
thread.last = null
|
||||
// Last message was removed but there might be older messages in the thread
|
||||
// that don't have expiration timestamp
|
||||
this.fetchSingleThread(token, threadId)
|
||||
}
|
||||
}
|
||||
},
|
||||
|
Reference in New Issue
Block a user