Fix unread markers not rendering with hidden status messages

Co-Authored-By: Richard Lewis <richrd@users.noreply.github.com>
This commit is contained in:
Pavel Djundik 2018-09-14 16:27:41 +03:00
parent 395be41728
commit b3e86dbab4

View File

@ -24,7 +24,7 @@
:key="message.id + '-date'" :key="message.id + '-date'"
:message="message" /> :message="message" />
<div <div
v-if="shouldDisplayUnreadMarker(id)" v-if="shouldDisplayUnreadMarker(message.id)"
:key="message.id + '-unread'" :key="message.id + '-unread'"
class="unread-marker"> class="unread-marker">
<span class="unread-marker-text" /> <span class="unread-marker-text" />
@ -188,6 +188,9 @@ export default {
} }
}); });
}, },
beforeUpdate() {
this.unreadMarkerShown = false;
},
beforeDestroy() { beforeDestroy() {
this.$root.$off("resize", this.handleResize); this.$root.$off("resize", this.handleResize);
this.$refs.chat.removeEventListener("scroll", this.debouncedScroll); this.$refs.chat.removeEventListener("scroll", this.debouncedScroll);
@ -208,13 +211,12 @@ export default {
return (new Date(previousMessage.time)).getDay() !== (new Date(message.time)).getDay(); return (new Date(previousMessage.time)).getDay() !== (new Date(message.time)).getDay();
}, },
shouldDisplayUnreadMarker(id) { shouldDisplayUnreadMarker(id) {
const previousMessage = this.condensedMessages[id - 1]; if (!this.unreadMarkerShown && id > this.channel.firstUnread) {
this.unreadMarkerShown = true;
if (!previousMessage) { return true;
return false;
} }
return this.channel.firstUnread === previousMessage.id; return false;
}, },
onCopy() { onCopy() {
clipboard(this.$el); clipboard(this.$el);