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
36 changes: 11 additions & 25 deletions src/components/MessagesList/MessagesGroup/Message/Message.vue
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,10 @@ the main body of the message as well as a quote.
:data-next-message-id="nextMessageId"
:data-previous-message-id="previousMessageId"
class="message"
:class="{'message__last': isLastMessage}"
:class="{'message__last': isLastMessage,
'message--highlighted': isHighlighted}"
tabindex="0"
@animationend="isHighlighted = false"
@mouseover="handleMouseover"
@mouseleave="handleMouseleave">
<div :class="{'normal-message-body': !isSystemMessage && !isDeletedMessage, 'system' : isSystemMessage}"
Expand Down Expand Up @@ -136,6 +138,7 @@ the main body of the message as well as a quote.
<NcPopover v-for="reaction in Object.keys(simpleReactions)"
:key="reaction"
:delay="200"
:focus-trap="false"
:triggers="['hover']">
<template #trigger>
<NcButton v-if="simpleReactions[reaction] !== 0"
Expand Down Expand Up @@ -419,11 +422,14 @@ export default {
return { isInCall, isTranslationAvailable }
},

expose: ['highlightMessage'],

data() {
return {
isHovered: false,
showReloadButton: false,
isDeleting: false,
isHighlighted: false,
// whether the message was seen, only used if this was marked as last read message
seen: false,
isActionMenuOpen: false,
Expand Down Expand Up @@ -678,20 +684,6 @@ export default {
},
},

mounted() {
// define a function, so it can be triggered directly on the DOM element
// which can be found with document.getElementById()
this.$refs.message.highlightAnimation = () => {
this.highlightAnimation()
}

this.$refs.message.addEventListener('animationend', this.highlightAnimationStop)
},

beforeDestroy() {
this.$refs.message.removeEventListener('animationend', this.highlightAnimationStop)
},

methods: {
userHasReacted(reaction) {
return this.reactionsSelf && this.reactionsSelf.includes(reaction)
Expand All @@ -703,13 +695,8 @@ export default {
}
},

highlightAnimation() {
// trigger CSS highlight animation by setting a class
this.$refs.message.classList.add('highlight-animation')
},
highlightAnimationStop() {
// when the animation ended, remove the class, so we can trigger it again another time
this.$refs.message.classList.remove('highlight-animation')
highlightMessage() {
this.isHighlighted = true
},

handleRetry() {
Expand Down Expand Up @@ -972,7 +959,7 @@ export default {
padding: 4px 4px 4px 8px;
}

.highlight-animation {
.message--highlighted {
animation: highlight-animation 5s 1;
border-radius: 8px;
}
Expand Down Expand Up @@ -1003,9 +990,8 @@ export default {
}

.message-status {
margin: -8px 0;
width: $clickable-area;
height: $clickable-area;
height: 24px;
display: flex;
justify-content: center;
align-items: center;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ describe('MessagesGroup.vue', () => {
propsData: {
id: 123,
token: TOKEN,
dateSeparator: '<date separator>',
previousMessageId: 90,
nextMessageId: 200,
messages: [{
Expand All @@ -50,7 +51,6 @@ describe('MessagesGroup.vue', () => {
systemMessage: '',
timestamp: 100,
isReplyable: true,
dateSeparator: '<date separator>',
}, {
id: 110,
token: TOKEN,
Expand Down Expand Up @@ -129,6 +129,7 @@ describe('MessagesGroup.vue', () => {
propsData: {
id: 123,
token: TOKEN,
dateSeparator: '<date separator>',
previousMessageId: 90,
nextMessageId: 200,
messages: [{
Expand All @@ -143,7 +144,6 @@ describe('MessagesGroup.vue', () => {
systemMessage: 'call_started',
timestamp: 100,
isReplyable: false,
dateSeparator: '<date separator>',
}, {
id: 110,
token: TOKEN,
Expand Down Expand Up @@ -197,6 +197,7 @@ describe('MessagesGroup.vue', () => {
propsData: {
id: 123,
token: TOKEN,
dateSeparator: '<date separator>',
previousMessageId: 90,
nextMessageId: 200,
messages: [{
Expand All @@ -211,7 +212,6 @@ describe('MessagesGroup.vue', () => {
systemMessage: '',
timestamp: 100,
isReplyable: true,
dateSeparator: '<date separator>',
}, {
id: 110,
token: TOKEN,
Expand Down Expand Up @@ -257,6 +257,7 @@ describe('MessagesGroup.vue', () => {
propsData: {
id: 123,
token: TOKEN,
dateSeparator: '<date separator>',
previousMessageId: 90,
nextMessageId: 200,
messages: [{
Expand All @@ -271,7 +272,6 @@ describe('MessagesGroup.vue', () => {
systemMessage: '',
timestamp: 100,
isReplyable: true,
dateSeparator: '<date separator>',
}, {
id: 110,
token: TOKEN,
Expand Down
29 changes: 21 additions & 8 deletions src/components/MessagesList/MessagesGroup/MessagesGroup.vue
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
<ul class="messages">
<Message v-for="(message, index) of messages"
:key="message.id"
ref="message"
v-bind="message"
:is-first-message="index === 0"
:next-message-id="(messages[index + 1] && messages[index + 1].id) || nextMessageId"
Expand Down Expand Up @@ -81,6 +82,13 @@ export default {
type: Array,
required: true,
},
/**
* The message date separator.
*/
dateSeparator: {
type: String,
required: true,
},

previousMessageId: {
type: [String, Number],
Expand All @@ -93,6 +101,8 @@ export default {
},
},

expose: ['highlightMessage'],

computed: {
/**
* The message actor type.
Expand All @@ -110,14 +120,6 @@ export default {
actorId() {
return this.messages[0].actorId
},
/**
* The message date.
*
* @return {string}
*/
dateSeparator() {
return this.messages[0].dateSeparator || ''
},
/**
* The message actor display name.
*
Expand Down Expand Up @@ -145,6 +147,17 @@ export default {
return this.messages[0].systemMessage.length !== 0
},
},

methods: {
highlightMessage(messageId) {
for (const message of this.$refs.message) {
if (message.id === messageId) {
message.highlightMessage()
break
}
}
},
},
}
</script>

Expand Down
Loading