2018-07-08 10:50:11 +00:00
|
|
|
<template>
|
|
|
|
<div
|
|
|
|
:id="'msg-' + message.id"
|
|
|
|
:class="['msg', message.type, {self: message.self, highlight: message.highlight}]"
|
|
|
|
:data-from="message.from && message.from.nick"
|
|
|
|
>
|
|
|
|
<span
|
|
|
|
:aria-label="message.time | localetime"
|
|
|
|
class="time tooltipped tooltipped-e">{{ message.time | tz }}</span>
|
|
|
|
<template v-if="message.type === 'unhandled'">
|
|
|
|
<span class="from">[{{ message.command }}]</span>
|
|
|
|
<span class="content">
|
|
|
|
<span
|
|
|
|
v-for="(param, id) in message.params"
|
2018-07-10 07:45:54 +00:00
|
|
|
: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()">
|
|
|
|
<span class="from"/>
|
|
|
|
<component
|
|
|
|
:is="messageComponent"
|
|
|
|
:message="message"/>
|
|
|
|
</template>
|
|
|
|
<template v-else>
|
2018-07-08 10:50:11 +00:00
|
|
|
<span class="from">
|
|
|
|
<template v-if="message.from && message.from.nick">
|
|
|
|
<Username :user="message.from"/>
|
|
|
|
</template>
|
|
|
|
</span>
|
|
|
|
<span class="content">
|
|
|
|
<span
|
2018-07-11 11:58:55 +00:00
|
|
|
ref="text"
|
2018-07-11 17:22:44 +00:00
|
|
|
class="text"><ParsedMessage :message="message"/></span>
|
2018-07-08 10:50:11 +00:00
|
|
|
|
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-10 11:57:11 +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-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-09 10:44:12 +00:00
|
|
|
computed: {
|
|
|
|
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>
|