Merge pull request #3993 from thelounge/xpaw/mentions-fix

Improvements to mentions window
This commit is contained in:
Pavel Djundik 2020-07-19 21:45:46 +03:00 committed by GitHub
commit 0ac1fcb471
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 31 additions and 3 deletions

View File

@ -8,13 +8,20 @@
<div class="mentions-popup"> <div class="mentions-popup">
<div class="mentions-popup-title"> <div class="mentions-popup-title">
Recent mentions Recent mentions
<button
v-if="resolvedMessages.length"
class="btn hide-all-mentions"
@click="hideAllMentions()"
>
Hide all
</button>
</div> </div>
<template v-if="resolvedMessages.length === 0"> <template v-if="resolvedMessages.length === 0">
<p v-if="isLoading">Loading</p> <p v-if="isLoading">Loading</p>
<p v-else>There are no recent mentions.</p> <p v-else>You have no recent mentions.</p>
</template> </template>
<template v-for="message in resolvedMessages" v-else> <template v-for="message in resolvedMessages" v-else>
<div :key="message.id" :class="['msg', message.type]"> <div :key="message.msgId" :class="['msg', message.type]">
<div class="mentions-info"> <div class="mentions-info">
<div> <div>
<span class="from"> <span class="from">
@ -62,12 +69,14 @@
right: 80px; right: 80px;
top: 55px; top: 55px;
max-height: 400px; max-height: 400px;
overflow-y: scroll; overflow-y: auto;
z-index: 2; z-index: 2;
padding: 10px; padding: 10px;
} }
.mentions-popup > .mentions-popup-title { .mentions-popup > .mentions-popup-title {
display: flex;
justify-content: space-between;
margin-bottom: 10px; margin-bottom: 10px;
font-size: 20px; font-size: 20px;
} }
@ -106,6 +115,17 @@
color: var(--link-color); color: var(--link-color);
} }
.mentions-popup .hide-all-mentions {
margin: 0;
padding: 4px 6px;
}
@media (min-height: 500px) {
.mentions-popup {
max-height: 60vh;
}
}
@media (max-width: 768px) { @media (max-width: 768px) {
.mentions-popup { .mentions-popup {
border-radius: 0; border-radius: 0;
@ -179,6 +199,10 @@ export default {
socket.emit("mentions:hide", message.msgId); socket.emit("mentions:hide", message.msgId);
}, },
hideAllMentions() {
this.$store.state.mentions = [];
socket.emit("mentions:hide_all");
},
containerClick(event) { containerClick(event) {
if (event.currentTarget === event.target) { if (event.currentTarget === event.target) {
this.isOpen = false; this.isOpen = false;

View File

@ -548,6 +548,10 @@ function initializeClient(socket, client, token, lastMessage, openChannel) {
); );
}); });
socket.on("mentions:hide_all", () => {
client.mentions = [];
});
if (!Helper.config.public) { if (!Helper.config.public) {
socket.on("push:register", (subscription) => { socket.on("push:register", (subscription) => {
if (!Object.prototype.hasOwnProperty.call(client.config.sessions, token)) { if (!Object.prototype.hasOwnProperty.call(client.config.sessions, token)) {