Merge pull request #3534 from thelounge/richrd/issue-659-previous-source

Add `previous-source` class to messages with same sender
This commit is contained in:
Pavel Djundik 2019-12-19 17:32:34 +02:00 committed by GitHub
commit bc6017aed7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 1 deletions

View File

@ -1,7 +1,10 @@
<template>
<div
:id="'msg-' + message.id"
:class="['msg', {self: message.self, highlight: message.highlight}]"
:class="[
'msg',
{self: message.self, highlight: message.highlight, 'previous-source': isPreviousSource},
]"
:data-type="message.type"
:data-from="message.from && message.from.nick"
>
@ -87,6 +90,7 @@ export default {
channel: Object,
network: Object,
keepScrollPosition: Function,
isPreviousSource: Boolean,
},
computed: {
messageTime() {

View File

@ -46,6 +46,7 @@
:network="network"
:message="message"
:keep-scroll-position="keepScrollPosition"
:is-previous-source="isPreviousSource(message, id)"
@linkPreviewToggle="onLinkPreviewToggle"
/>
</template>
@ -212,6 +213,16 @@ export default {
return false;
},
isPreviousSource(currentMessage, id) {
const previousMessage = this.condensedMessages[id - 1];
return (
previousMessage &&
currentMessage.type === "message" &&
previousMessage.type === "message" &&
previousMessage.from &&
currentMessage.from.nick === previousMessage.from.nick
);
},
onCopy() {
clipboard(this.$el);
},