2019-11-04 09:21:05 +00:00
|
|
|
|
<template>
|
|
|
|
|
<div
|
|
|
|
|
v-if="isOpen"
|
|
|
|
|
id="mentions-popup-container"
|
|
|
|
|
@click="containerClick"
|
2020-04-20 10:40:45 +00:00
|
|
|
|
@contextmenu="containerClick"
|
2019-11-04 09:21:05 +00:00
|
|
|
|
>
|
|
|
|
|
<div class="mentions-popup">
|
|
|
|
|
<div class="mentions-popup-title">
|
|
|
|
|
Recent mentions
|
2020-07-19 14:29:52 +00:00
|
|
|
|
<button
|
|
|
|
|
v-if="resolvedMessages.length"
|
|
|
|
|
class="btn hide-all-mentions"
|
|
|
|
|
@click="hideAllMentions()"
|
|
|
|
|
>
|
|
|
|
|
Hide all
|
|
|
|
|
</button>
|
2019-11-04 09:21:05 +00:00
|
|
|
|
</div>
|
|
|
|
|
<template v-if="resolvedMessages.length === 0">
|
2020-04-13 07:59:18 +00:00
|
|
|
|
<p v-if="isLoading">Loading…</p>
|
2020-07-19 14:29:52 +00:00
|
|
|
|
<p v-else>You have no recent mentions.</p>
|
2019-11-04 09:21:05 +00:00
|
|
|
|
</template>
|
|
|
|
|
<template v-for="message in resolvedMessages" v-else>
|
2020-07-19 14:29:52 +00:00
|
|
|
|
<div :key="message.msgId" :class="['msg', message.type]">
|
2020-04-20 10:40:45 +00:00
|
|
|
|
<div class="mentions-info">
|
|
|
|
|
<div>
|
|
|
|
|
<span class="from">
|
|
|
|
|
<Username :user="message.from" />
|
|
|
|
|
<template v-if="message.channel">
|
|
|
|
|
in {{ message.channel.channel.name }} on
|
|
|
|
|
{{ message.channel.network.name }}
|
|
|
|
|
</template>
|
2020-08-25 09:49:53 +00:00
|
|
|
|
<template v-else> in unknown channel </template>
|
2020-04-20 10:40:45 +00:00
|
|
|
|
</span>
|
|
|
|
|
<span :title="message.localetime" class="time">
|
|
|
|
|
{{ messageTime(message.time) }}
|
|
|
|
|
</span>
|
|
|
|
|
</div>
|
|
|
|
|
<div>
|
|
|
|
|
<span class="close-tooltip tooltipped tooltipped-w" aria-label="Close">
|
|
|
|
|
<button
|
|
|
|
|
class="msg-hide"
|
|
|
|
|
aria-label="Hide this mention"
|
|
|
|
|
@click="hideMention(message)"
|
|
|
|
|
></button>
|
|
|
|
|
</span>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
2019-11-04 09:21:05 +00:00
|
|
|
|
<div class="content" dir="auto">
|
|
|
|
|
<ParsedMessage :network="null" :message="message" />
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<style>
|
2020-04-13 09:31:56 +00:00
|
|
|
|
#mentions-popup-container {
|
|
|
|
|
z-index: 8;
|
|
|
|
|
}
|
|
|
|
|
|
2019-11-04 09:21:05 +00:00
|
|
|
|
.mentions-popup {
|
|
|
|
|
background-color: var(--window-bg-color);
|
|
|
|
|
position: absolute;
|
|
|
|
|
width: 400px;
|
|
|
|
|
right: 80px;
|
|
|
|
|
top: 55px;
|
|
|
|
|
max-height: 400px;
|
2020-07-19 14:29:52 +00:00
|
|
|
|
overflow-y: auto;
|
2019-11-04 09:21:05 +00:00
|
|
|
|
z-index: 2;
|
|
|
|
|
padding: 10px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.mentions-popup > .mentions-popup-title {
|
2020-07-19 14:29:52 +00:00
|
|
|
|
display: flex;
|
|
|
|
|
justify-content: space-between;
|
2019-11-04 09:21:05 +00:00
|
|
|
|
margin-bottom: 10px;
|
|
|
|
|
font-size: 20px;
|
|
|
|
|
}
|
|
|
|
|
|
2020-04-20 10:40:45 +00:00
|
|
|
|
.mentions-popup .mentions-info {
|
|
|
|
|
display: flex;
|
|
|
|
|
justify-content: space-between;
|
|
|
|
|
}
|
|
|
|
|
|
2019-11-04 09:21:05 +00:00
|
|
|
|
.mentions-popup .msg {
|
|
|
|
|
margin-bottom: 15px;
|
|
|
|
|
user-select: text;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.mentions-popup .msg:last-child {
|
|
|
|
|
margin-bottom: 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.mentions-popup .msg .content {
|
|
|
|
|
background-color: var(--highlight-bg-color);
|
|
|
|
|
border-radius: 5px;
|
|
|
|
|
padding: 6px;
|
|
|
|
|
margin-top: 2px;
|
2020-07-27 14:27:06 +00:00
|
|
|
|
word-wrap: break-word;
|
|
|
|
|
word-break: break-word; /* Webkit-specific */
|
2019-11-04 09:21:05 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.mentions-popup .msg-hide::before {
|
|
|
|
|
font-size: 20px;
|
|
|
|
|
font-weight: normal;
|
|
|
|
|
display: inline-block;
|
|
|
|
|
line-height: 16px;
|
|
|
|
|
text-align: center;
|
|
|
|
|
content: "×";
|
|
|
|
|
}
|
|
|
|
|
|
2020-04-20 10:40:45 +00:00
|
|
|
|
.mentions-popup .msg-hide:hover {
|
|
|
|
|
color: var(--link-color);
|
|
|
|
|
}
|
|
|
|
|
|
2020-07-19 14:29:52 +00:00
|
|
|
|
.mentions-popup .hide-all-mentions {
|
|
|
|
|
margin: 0;
|
|
|
|
|
padding: 4px 6px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@media (min-height: 500px) {
|
|
|
|
|
.mentions-popup {
|
|
|
|
|
max-height: 60vh;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-11-04 09:21:05 +00:00
|
|
|
|
@media (max-width: 768px) {
|
|
|
|
|
.mentions-popup {
|
|
|
|
|
border-radius: 0;
|
|
|
|
|
border: 0;
|
|
|
|
|
box-shadow: none;
|
|
|
|
|
width: 100%;
|
|
|
|
|
max-height: none;
|
|
|
|
|
right: 0;
|
|
|
|
|
left: 0;
|
|
|
|
|
bottom: 0;
|
|
|
|
|
top: 45px; /* header height */
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</style>
|
|
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
import Username from "./Username.vue";
|
|
|
|
|
import ParsedMessage from "./ParsedMessage.vue";
|
|
|
|
|
import socket from "../js/socket";
|
2020-03-16 17:58:40 +00:00
|
|
|
|
import eventbus from "../js/eventbus";
|
2020-04-20 10:40:45 +00:00
|
|
|
|
import localetime from "../js/helpers/localetime";
|
2019-11-04 09:21:05 +00:00
|
|
|
|
import dayjs from "dayjs";
|
|
|
|
|
import relativeTime from "dayjs/plugin/relativeTime";
|
|
|
|
|
|
|
|
|
|
dayjs.extend(relativeTime);
|
|
|
|
|
|
|
|
|
|
export default {
|
|
|
|
|
name: "Mentions",
|
|
|
|
|
components: {
|
|
|
|
|
Username,
|
|
|
|
|
ParsedMessage,
|
|
|
|
|
},
|
|
|
|
|
data() {
|
|
|
|
|
return {
|
|
|
|
|
isOpen: false,
|
|
|
|
|
isLoading: false,
|
|
|
|
|
};
|
|
|
|
|
},
|
|
|
|
|
computed: {
|
|
|
|
|
resolvedMessages() {
|
|
|
|
|
const messages = this.$store.state.mentions.slice().reverse();
|
|
|
|
|
|
|
|
|
|
for (const message of messages) {
|
2020-04-20 10:40:45 +00:00
|
|
|
|
message.localetime = localetime(message.time);
|
2019-11-04 09:21:05 +00:00
|
|
|
|
message.channel = this.$store.getters.findChannel(message.chanId);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return messages;
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
watch: {
|
|
|
|
|
"$store.state.mentions"() {
|
|
|
|
|
this.isLoading = false;
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
mounted() {
|
2020-03-16 17:58:40 +00:00
|
|
|
|
eventbus.on("mentions:toggle", this.openPopup);
|
2019-11-04 09:21:05 +00:00
|
|
|
|
},
|
|
|
|
|
destroyed() {
|
2020-03-16 17:58:40 +00:00
|
|
|
|
eventbus.off("mentions:toggle", this.openPopup);
|
2019-11-04 09:21:05 +00:00
|
|
|
|
},
|
|
|
|
|
methods: {
|
|
|
|
|
messageTime(time) {
|
|
|
|
|
return dayjs(time).fromNow();
|
|
|
|
|
},
|
|
|
|
|
hideMention(message) {
|
|
|
|
|
this.$store.state.mentions.splice(
|
|
|
|
|
this.$store.state.mentions.findIndex((m) => m.msgId === message.msgId),
|
|
|
|
|
1
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
socket.emit("mentions:hide", message.msgId);
|
|
|
|
|
},
|
2020-07-19 14:29:52 +00:00
|
|
|
|
hideAllMentions() {
|
|
|
|
|
this.$store.state.mentions = [];
|
|
|
|
|
socket.emit("mentions:hide_all");
|
|
|
|
|
},
|
2019-11-04 09:21:05 +00:00
|
|
|
|
containerClick(event) {
|
|
|
|
|
if (event.currentTarget === event.target) {
|
|
|
|
|
this.isOpen = false;
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
openPopup() {
|
|
|
|
|
this.isOpen = !this.isOpen;
|
|
|
|
|
|
|
|
|
|
if (this.isOpen) {
|
|
|
|
|
this.isLoading = true;
|
|
|
|
|
socket.emit("mentions:get");
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
</script>
|