2018-07-08 10:50:11 +00:00
|
|
|
<template>
|
|
|
|
<div
|
|
|
|
:id="'msg-' + message.id"
|
|
|
|
:class="['msg', message.type, {self: message.self, highlight: message.highlight}]"
|
2019-02-25 05:38:13 +00:00
|
|
|
:data-from="message.from && message.from.nick"
|
|
|
|
>
|
2019-07-17 09:33:59 +00:00
|
|
|
<span :aria-label="message.time | localetime" class="time tooltipped tooltipped-e"
|
|
|
|
>{{ 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()">
|
2018-09-26 08:32:38 +00:00
|
|
|
<span class="from"><span class="only-copy">*** </span></span>
|
2019-07-17 09:33:59 +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'">
|
2018-09-26 08:32:38 +00:00
|
|
|
<span class="from"><span class="only-copy">* </span></span>
|
2018-07-13 10:43:11 +00:00
|
|
|
<span class="content">
|
2018-09-26 08:32:38 +00:00
|
|
|
<Username :user="message.from" /> <ParsedMessage
|
2018-07-19 17:44:24 +00:00
|
|
|
:network="network"
|
2019-02-25 05:38:13 +00:00
|
|
|
: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"
|
|
|
|
/>
|
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">
|
2018-09-26 08:32:38 +00:00
|
|
|
<span class="only-copy"><</span>
|
2018-07-29 17:57:14 +00:00
|
|
|
<Username :user="message.from" />
|
2018-09-26 08:32:38 +00:00
|
|
|
<span class="only-copy">> </span>
|
|
|
|
</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">
|
|
|
|
<span class="only-copy">-</span>
|
|
|
|
<Username :user="message.from" />
|
|
|
|
<span class="only-copy">- </span>
|
2018-07-08 10:50:11 +00:00
|
|
|
</template>
|
|
|
|
</span>
|
|
|
|
<span class="content">
|
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"
|
|
|
|
/>
|
2018-07-08 10:50:11 +00:00
|
|
|
</span>
|
|
|
|
</template>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
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
|
|
|
const moment = require("moment");
|
|
|
|
const constants = require("../js/constants");
|
|
|
|
|
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,
|
2018-07-19 17:44:24 +00:00
|
|
|
network: Object,
|
2018-07-13 10:43:11 +00:00
|
|
|
keepScrollPosition: Function,
|
2018-07-08 10:50:11 +00:00
|
|
|
},
|
2018-07-09 10:44:12 +00:00
|
|
|
computed: {
|
2018-09-13 09:16:27 +00:00
|
|
|
messageTime() {
|
2019-07-17 09:33:59 +00:00
|
|
|
const format = this.$root.settings.showSeconds
|
|
|
|
? constants.timeFormats.msgWithSeconds
|
|
|
|
: constants.timeFormats.msgDefault;
|
2018-09-13 09:16:27 +00:00
|
|
|
|
|
|
|
return moment(this.message.time).format(format);
|
|
|
|
},
|
2018-07-09 10:44:12 +00:00
|
|
|
messageComponent() {
|
|
|
|
return "message-" + this.message.type;
|
|
|
|
},
|
|
|
|
},
|
2018-07-11 11:33:06 +00:00
|
|
|
mounted() {
|
|
|
|
require("../js/renderPreview");
|
|
|
|
},
|
2018-07-09 10:44:12 +00:00
|
|
|
methods: {
|
|
|
|
isAction() {
|
|
|
|
return typeof MessageTypes["message-" + this.message.type] !== "undefined";
|
|
|
|
},
|
|
|
|
},
|
2018-07-08 10:50:11 +00:00
|
|
|
};
|
|
|
|
</script>
|