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> <template>
<div <div
:id="'msg-' + message.id" :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-type="message.type"
:data-from="message.from && message.from.nick" :data-from="message.from && message.from.nick"
> >
@ -87,6 +90,7 @@ export default {
channel: Object, channel: Object,
network: Object, network: Object,
keepScrollPosition: Function, keepScrollPosition: Function,
isPreviousSource: Boolean,
}, },
computed: { computed: {
messageTime() { messageTime() {

View File

@ -46,6 +46,7 @@
:network="network" :network="network"
:message="message" :message="message"
:keep-scroll-position="keepScrollPosition" :keep-scroll-position="keepScrollPosition"
:is-previous-source="isPreviousSource(message, id)"
@linkPreviewToggle="onLinkPreviewToggle" @linkPreviewToggle="onLinkPreviewToggle"
/> />
</template> </template>
@ -212,6 +213,16 @@ export default {
return false; 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() { onCopy() {
clipboard(this.$el); clipboard(this.$el);
}, },