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
10 changes: 9 additions & 1 deletion src/components/TopBar/TopBar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
:tabindex="0"
:title="t('spreed', 'Back')"
:aria-label="t('spreed', 'Back')"
@click="currentThread ? threadId = 0 : openConversationSettings()">
@click="handleClickAvatar">
<IconArrowLeft
v-show="currentThread"
class="top-bar__icon-back bidirectional-icon"
Expand Down Expand Up @@ -398,6 +398,14 @@ export default {
this.sidebarStore.showSidebar({ activeTab })
},

handleClickAvatar() {
if (this.currentThread) {
this.$router.replace({ query: {}, hash: '' })
} else {
this.openConversationSettings()
}
},

openConversationSettings() {
emit('show-conversation-settings', { token: this.token })
},
Expand Down
32 changes: 17 additions & 15 deletions src/composables/useGetMessages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,14 @@ export function useGetMessagesProvider() {
})

const conversationLastMessageId = computed<number>(() => {
if (contextThreadId.value) {
const threadInfo = chatExtrasStore.threads[currentToken.value]?.[contextThreadId.value]
// If threadId is set, we should compare with last message from the thread
if (threadInfo) {
return threadInfo.last?.id ?? contextThreadId.value
}
}

if (conversation.value?.lastMessage && 'id' in conversation.value.lastMessage) {
return conversation.value.lastMessage.id
}
Expand All @@ -123,14 +131,6 @@ export function useGetMessagesProvider() {

const lastKnownMessageId = chatStore.getLastKnownId(currentToken.value, { messageId: contextMessageId.value, threadId: contextThreadId.value })

if (contextThreadId.value) {
const threadInfo = chatExtrasStore.threads[currentToken.value]?.[contextThreadId.value]
// If threadId is set, we should compare with last message from the thread
if (threadInfo?.last) {
return lastKnownMessageId >= threadInfo.last.id
}
}

return lastKnownMessageId >= conversationLastMessageId.value
})

Expand Down Expand Up @@ -223,15 +223,17 @@ export function useGetMessagesProvider() {
}

const focusMessageId = getMessageIdFromHash(to.hash)
if (from.hash !== to.hash && focusMessageId !== null) {
// the hash changed, need to focus/highlight another message
if (focusMessageId !== null) {
// the hash is non-empty, need to focus/highlight another message
contextMessageId.value = focusMessageId
} else if (conversation.value?.lastReadMessage && conversation.value.lastReadMessage > contextMessageId.value) {
// focus last read message first
contextMessageId.value = conversation.value.lastReadMessage
} else {
// last known message in the most recent block store
contextMessageId.value = conversationLastMessageId.value
// try to focus last read message first, otherwise scroll to last known message in the most recent block store
const hasLastReadMessageInContextBelow = conversation.value?.lastReadMessage && conversation.value.lastReadMessage > contextMessageId.value
&& (!contextThreadId.value || chatStore.hasMessage(to.params.token, { messageId: conversation.value.lastReadMessage, threadId: contextThreadId.value }))

contextMessageId.value = hasLastReadMessageInContextBelow
? conversation.value.lastReadMessage
: conversationLastMessageId.value
}

await checkContextAndFocusMessage(to.params.token, contextMessageId.value, contextThreadId.value)
Expand Down
3 changes: 2 additions & 1 deletion src/store/messagesStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -904,6 +904,7 @@ const actions = {
&& message.systemMessage !== 'reaction_deleted'
&& message.systemMessage !== 'reaction_revoked'
&& message.systemMessage !== 'poll_voted'
// FIXME filter thread messages in general view
) {
minimumVisible--
}
Expand Down Expand Up @@ -995,6 +996,7 @@ const actions = {
&& message.systemMessage !== 'reaction_deleted'
&& message.systemMessage !== 'reaction_revoked'
&& message.systemMessage !== 'poll_voted'
// FIXME filter thread messages in general view
) {
minimumVisible--
}
Expand Down Expand Up @@ -1260,7 +1262,6 @@ const actions = {
context.dispatch('processMessage', { token, message: response.data.ocs.data })
chatStore.processChatBlocks(token, [response.data.ocs.data], {
mergeBy: conversationLastMessageId,
threadId: response.data.ocs.data.threadId,
})
}

Expand Down
Loading
Loading