2018-07-08 10:50:11 +00:00
|
|
|
<template>
|
|
|
|
<div
|
|
|
|
:id="'msg-' + message.id"
|
2019-11-27 00:56:57 +00:00
|
|
|
:class="[
|
|
|
|
'msg',
|
2021-01-26 22:51:22 +00:00
|
|
|
{
|
|
|
|
self: message.self,
|
|
|
|
highlight: message.highlight || focused,
|
|
|
|
'previous-source': isPreviousSource,
|
|
|
|
},
|
2019-11-27 00:56:57 +00:00
|
|
|
]"
|
2019-12-15 11:46:43 +00:00
|
|
|
:data-type="message.type"
|
2020-06-29 07:51:17 +00:00
|
|
|
:data-command="message.command"
|
2019-02-25 05:38:13 +00:00
|
|
|
:data-from="message.from && message.from.nick"
|
|
|
|
>
|
2021-04-21 01:04:31 +00:00
|
|
|
<span
|
|
|
|
aria-hidden="true"
|
|
|
|
:aria-label="messageTimeLocale"
|
|
|
|
class="time tooltipped tooltipped-e"
|
2022-02-21 20:38:50 +00:00
|
|
|
>{{ messageTime }}
|
|
|
|
</span>
|
2018-07-08 10:50:11 +00:00
|
|
|
<template v-if="message.type === 'unhandled'">
|
|
|
|
<span class="from">[{{ message.command }}]</span>
|
|
|
|
<span class="content">
|
2019-07-17 09:33:59 +00:00
|
|
|
<span v-for="(param, id) in message.params" :key="id">{{ param }} </span>
|
2018-07-08 10:50:11 +00:00
|
|
|
</span>
|
|
|
|
</template>
|
2018-07-09 10:44:12 +00:00
|
|
|
<template v-else-if="isAction()">
|
2022-02-12 12:59:29 +00:00
|
|
|
<span class="from"><span class="only-copy">*** </span></span>
|
2020-04-28 14:17:55 +00:00
|
|
|
<component :is="messageComponent" :network="network" :message="message" />
|
2018-07-09 10:44:12 +00:00
|
|
|
</template>
|
2018-07-13 10:49:09 +00:00
|
|
|
<template v-else-if="message.type === 'action'">
|
2022-02-12 12:59:29 +00:00
|
|
|
<span class="from"><span class="only-copy">* </span></span>
|
2019-08-03 12:35:13 +00:00
|
|
|
<span class="content" dir="auto">
|
2020-04-24 07:20:40 +00:00
|
|
|
<Username
|
|
|
|
:user="message.from"
|
|
|
|
:network="network"
|
|
|
|
:channel="channel"
|
|
|
|
dir="auto"
|
|
|
|
/> <ParsedMessage :message="message" />
|
2018-07-13 10:43:11 +00:00
|
|
|
<LinkPreview
|
|
|
|
v-for="preview in message.previews"
|
|
|
|
:key="preview.link"
|
2018-07-29 17:57:14 +00:00
|
|
|
:keep-scroll-position="keepScrollPosition"
|
2019-02-25 05:38:13 +00:00
|
|
|
:link="preview"
|
2020-03-09 16:39:05 +00:00
|
|
|
:channel="channel"
|
2019-02-25 05:38:13 +00:00
|
|
|
/>
|
2018-07-13 10:43:11 +00:00
|
|
|
</span>
|
|
|
|
</template>
|
2018-07-09 10:44:12 +00:00
|
|
|
<template v-else>
|
2019-07-17 09:33:59 +00:00
|
|
|
<span v-if="message.type === 'message'" class="from">
|
2018-07-08 10:50:11 +00:00
|
|
|
<template v-if="message.from && message.from.nick">
|
2021-04-21 01:04:31 +00:00
|
|
|
<span class="only-copy" aria-hidden="true"><</span>
|
2020-04-24 07:20:40 +00:00
|
|
|
<Username :user="message.from" :network="network" :channel="channel" />
|
2022-02-12 12:59:29 +00:00
|
|
|
<span class="only-copy" aria-hidden="true">> </span>
|
2018-09-26 08:32:38 +00:00
|
|
|
</template>
|
|
|
|
</span>
|
2019-10-22 16:44:05 +00:00
|
|
|
<span v-else-if="message.type === 'plugin'" class="from">
|
|
|
|
<template v-if="message.from && message.from.nick">
|
2021-04-21 01:04:31 +00:00
|
|
|
<span class="only-copy" aria-hidden="true">[</span>
|
2019-10-22 17:38:13 +00:00
|
|
|
{{ message.from.nick }}
|
2022-02-12 12:59:29 +00:00
|
|
|
<span class="only-copy" aria-hidden="true">] </span>
|
2019-10-22 16:44:05 +00:00
|
|
|
</template>
|
|
|
|
</span>
|
2019-07-17 09:33:59 +00:00
|
|
|
<span v-else class="from">
|
2018-09-26 08:32:38 +00:00
|
|
|
<template v-if="message.from && message.from.nick">
|
2021-04-21 01:04:31 +00:00
|
|
|
<span class="only-copy" aria-hidden="true">-</span>
|
2020-04-24 07:20:40 +00:00
|
|
|
<Username :user="message.from" :network="network" :channel="channel" />
|
2022-02-12 12:59:29 +00:00
|
|
|
<span class="only-copy" aria-hidden="true">- </span>
|
2018-07-08 10:50:11 +00:00
|
|
|
</template>
|
|
|
|
</span>
|
2019-08-03 12:35:13 +00:00
|
|
|
<span class="content" dir="auto">
|
2020-01-05 16:27:34 +00:00
|
|
|
<span
|
|
|
|
v-if="message.showInActive"
|
|
|
|
aria-label="This message was shown in your active channel"
|
|
|
|
class="msg-shown-in-active tooltipped tooltipped-e"
|
|
|
|
><span></span
|
|
|
|
></span>
|
2020-04-24 08:46:39 +00:00
|
|
|
<span
|
|
|
|
v-if="message.statusmsgGroup"
|
|
|
|
:aria-label="`This message was only shown to users with ${message.statusmsgGroup} mode`"
|
|
|
|
class="msg-statusmsg tooltipped tooltipped-e"
|
|
|
|
><span>{{ message.statusmsgGroup }}</span></span
|
|
|
|
>
|
2019-07-17 09:33:59 +00:00
|
|
|
<ParsedMessage :network="network" :message="message" />
|
2018-07-10 11:57:11 +00:00
|
|
|
<LinkPreview
|
2018-07-08 10:50:11 +00:00
|
|
|
v-for="preview in message.previews"
|
|
|
|
:key="preview.link"
|
2018-07-29 17:57:14 +00:00
|
|
|
:keep-scroll-position="keepScrollPosition"
|
2019-02-25 05:38:13 +00:00
|
|
|
:link="preview"
|
2020-03-09 16:39:05 +00:00
|
|
|
:channel="channel"
|
2019-02-25 05:38:13 +00:00
|
|
|
/>
|
2018-07-08 10:50:11 +00:00
|
|
|
</span>
|
|
|
|
</template>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2019-12-17 22:10:50 +00:00
|
|
|
const constants = require("../js/constants");
|
2020-01-08 09:11:44 +00:00
|
|
|
import localetime from "../js/helpers/localetime";
|
2019-11-14 15:30:42 +00:00
|
|
|
import dayjs from "dayjs";
|
2018-07-08 10:50:11 +00:00
|
|
|
import Username from "./Username.vue";
|
2018-07-10 11:57:11 +00:00
|
|
|
import LinkPreview from "./LinkPreview.vue";
|
2018-07-11 17:22:44 +00:00
|
|
|
import ParsedMessage from "./ParsedMessage.vue";
|
2018-07-09 10:44:12 +00:00
|
|
|
import MessageTypes from "./MessageTypes";
|
2018-09-13 09:16:27 +00:00
|
|
|
|
2018-07-11 17:22:44 +00:00
|
|
|
MessageTypes.ParsedMessage = ParsedMessage;
|
2018-07-10 11:57:11 +00:00
|
|
|
MessageTypes.LinkPreview = LinkPreview;
|
2018-07-09 10:44:12 +00:00
|
|
|
MessageTypes.Username = Username;
|
2018-07-08 10:50:11 +00:00
|
|
|
|
|
|
|
export default {
|
|
|
|
name: "Message",
|
2018-07-09 10:44:12 +00:00
|
|
|
components: MessageTypes,
|
2018-07-08 10:50:11 +00:00
|
|
|
props: {
|
|
|
|
message: Object,
|
2019-11-09 22:21:34 +00:00
|
|
|
channel: Object,
|
2018-07-19 17:44:24 +00:00
|
|
|
network: Object,
|
2018-07-13 10:43:11 +00:00
|
|
|
keepScrollPosition: Function,
|
2019-11-27 00:56:57 +00:00
|
|
|
isPreviousSource: Boolean,
|
2021-01-26 22:51:22 +00:00
|
|
|
focused: Boolean,
|
2018-07-08 10:50:11 +00:00
|
|
|
},
|
2018-07-09 10:44:12 +00:00
|
|
|
computed: {
|
2020-02-29 09:37:45 +00:00
|
|
|
timeFormat() {
|
|
|
|
let format;
|
|
|
|
|
|
|
|
if (this.$store.state.settings.use12hClock) {
|
|
|
|
format = this.$store.state.settings.showSeconds ? "msg12hWithSeconds" : "msg12h";
|
|
|
|
} else {
|
|
|
|
format = this.$store.state.settings.showSeconds ? "msgWithSeconds" : "msgDefault";
|
|
|
|
}
|
2018-09-13 09:16:27 +00:00
|
|
|
|
2020-02-29 09:37:45 +00:00
|
|
|
return constants.timeFormats[format];
|
|
|
|
},
|
|
|
|
messageTime() {
|
|
|
|
return dayjs(this.message.time).format(this.timeFormat);
|
2018-09-13 09:16:27 +00:00
|
|
|
},
|
2020-01-08 09:11:44 +00:00
|
|
|
messageTimeLocale() {
|
|
|
|
return localetime(this.message.time);
|
|
|
|
},
|
2018-07-09 10:44:12 +00:00
|
|
|
messageComponent() {
|
|
|
|
return "message-" + this.message.type;
|
|
|
|
},
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
isAction() {
|
|
|
|
return typeof MessageTypes["message-" + this.message.type] !== "undefined";
|
|
|
|
},
|
|
|
|
},
|
2018-07-08 10:50:11 +00:00
|
|
|
};
|
|
|
|
</script>
|