Skip to content

Commit

Permalink
expand system messages group if visual unread marker is set on it
Browse files Browse the repository at this point in the history
Signed-off-by: Maksim Sukharev <antreesy.web@gmail.com>
  • Loading branch information
Antreesy authored and backportbot-nextcloud[bot] committed Dec 1, 2023
1 parent 28bf19c commit 5333708
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 8 deletions.
9 changes: 4 additions & 5 deletions src/components/MessagesList/MessagesGroup/Message/Message.vue
Original file line number Diff line number Diff line change
Expand Up @@ -235,10 +235,9 @@ the main body of the message as well as a quote.
@close="isTranslateDialogOpen = false" />

<div v-if="isLastReadMessage"
v-observe-visibility="lastReadMessageVisibilityChanged">
<div class="new-message-marker">
<span>{{ t('spreed', 'Unread messages') }}</span>
</div>
v-observe-visibility="lastReadMessageVisibilityChanged"
class="new-message-marker">
<span>{{ t('spreed', 'Unread messages') }}</span>
</div>
</li>
</template>
Expand Down Expand Up @@ -1052,7 +1051,7 @@ export default {

.new-message-marker {
position: relative;
margin: 20px 15px 20px -45px;
margin: 20px 15px;
border-top: 1px solid var(--color-border);

span {
Expand Down
16 changes: 13 additions & 3 deletions src/components/MessagesList/MessagesGroup/MessagesSystemGroup.vue
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,12 @@ export default {
}
},

computed: {
lastReadMessageId() {
return this.$store.getters.conversation(this.token)?.lastReadMessage
}

Check warning on line 110 in src/components/MessagesList/MessagesGroup/MessagesSystemGroup.vue

View workflow job for this annotation

GitHub Actions / eslint

Missing trailing comma
},

watch: {
messages: {
deep: true,
Expand Down Expand Up @@ -186,24 +192,28 @@ export default {
let lastMessage = null
let forceNextGroup = false
for (const message of messages) {
const isLastRead = message.id === this.lastReadMessageId
const groupingType = this.messagesShouldBeGrouped(message, lastMessage)
if (!groupingType || forceNextGroup) {
groups.push({ id: message.id, messages: [message], type: '', collapsed: this.groupIsCollapsed[message.id] ?? true })
groups.push({ id: message.id, messages: [message], type: '', collapsed: this.groupIsCollapsed[message.id] ?? !isLastRead })
forceNextGroup = false
} else {
if (groupingType === 'call_reconnected') {
groups.push({ id: message.id, messages: [groups.at(-1).messages.pop()], type: '', collapsed: this.groupIsCollapsed[message.id] ?? true })
groups.push({ id: message.id, messages: [groups.at(-1).messages.pop()], type: '', collapsed: this.groupIsCollapsed[message.id] ?? !isLastRead })
forceNextGroup = true
}
groups.at(-1).messages.push(message)
groups.at(-1).type = groupingType
if (isLastRead) {
groups.at(-1).collapsed = false
}
}
lastMessage = message
}

groups.forEach(group => {
if (this.groupIsCollapsed[group.id] === undefined) {
this.groupIsCollapsed[group.id] = true
this.groupIsCollapsed[group.id] = group.collapsed
}
})
return groups
Expand Down
1 change: 1 addition & 0 deletions src/composables/useCombinedSystemMessage.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ export function useCombinedSystemMessage() {
*/
function createCombinedSystemMessage({ id, messages, type, collapsed }) {
const combinedMessage = cloneDeep(messages[0])
combinedMessage.id = messages[0].id + '_combined'

// Handle cases when users reconnected to the call
if (type === 'call_reconnected') {
Expand Down

0 comments on commit 5333708

Please sign in to comment.