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-06-19 00:25:21 +00:00
|
|
|
>{{ `${messageTime} ` }}
|
2022-02-21 20:38:50 +00:00
|
|
|
</span>
|
2018-07-08 10:50:11 +00:00
|
|
|
<template v-if="message.type === 'unhandled'">
|
|
|
|
<span class="from">[{{ message.command }}]</span>
|
|
|
|
<span class="content">
|
2022-06-19 00:25:21 +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>
|
|
|
|
|
2022-06-19 00:25:21 +00:00
|
|
|
<script lang="ts">
|
|
|
|
import {computed, defineComponent, PropType} from "vue";
|
2019-11-14 15:30:42 +00:00
|
|
|
import dayjs from "dayjs";
|
2022-06-19 00:25:21 +00:00
|
|
|
|
|
|
|
import constants from "../js/constants";
|
|
|
|
import localetime from "../js/helpers/localetime";
|
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
|
|
|
|
2022-06-19 00:25:21 +00:00
|
|
|
import type {ClientChan, ClientMessage, ClientNetwork} from "../js/types";
|
|
|
|
import {useStore} from "../js/store";
|
|
|
|
|
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
|
|
|
|
2022-06-19 00:25:21 +00:00
|
|
|
export default defineComponent({
|
2018-07-08 10:50:11 +00:00
|
|
|
name: "Message",
|
2018-07-09 10:44:12 +00:00
|
|
|
components: MessageTypes,
|
2018-07-08 10:50:11 +00:00
|
|
|
props: {
|
2022-06-19 00:25:21 +00:00
|
|
|
message: {type: Object as PropType<ClientMessage>, required: true},
|
|
|
|
channel: {type: Object as PropType<ClientChan>, required: false},
|
|
|
|
network: {type: Object as PropType<ClientNetwork>, required: true},
|
|
|
|
keepScrollPosition: Function as PropType<() => void>,
|
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
|
|
|
},
|
2022-06-19 00:25:21 +00:00
|
|
|
setup(props) {
|
|
|
|
const store = useStore();
|
|
|
|
|
|
|
|
const timeFormat = computed(() => {
|
|
|
|
let format: keyof typeof constants.timeFormats;
|
2020-02-29 09:37:45 +00:00
|
|
|
|
2022-06-19 00:25:21 +00:00
|
|
|
if (store.state.settings.use12hClock) {
|
|
|
|
format = store.state.settings.showSeconds ? "msg12hWithSeconds" : "msg12h";
|
2020-02-29 09:37:45 +00:00
|
|
|
} else {
|
2022-06-19 00:25:21 +00:00
|
|
|
format = store.state.settings.showSeconds ? "msgWithSeconds" : "msgDefault";
|
2020-02-29 09:37:45 +00:00
|
|
|
}
|
2018-09-13 09:16:27 +00:00
|
|
|
|
2020-02-29 09:37:45 +00:00
|
|
|
return constants.timeFormats[format];
|
2022-06-19 00:25:21 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
const messageTime = computed(() => {
|
|
|
|
return dayjs(props.message.time).format(timeFormat.value);
|
|
|
|
});
|
|
|
|
|
|
|
|
const messageTimeLocale = computed(() => {
|
|
|
|
return localetime(props.message.time);
|
|
|
|
});
|
|
|
|
|
|
|
|
const messageComponent = computed(() => {
|
|
|
|
return "message-" + props.message.type;
|
|
|
|
});
|
|
|
|
|
|
|
|
const isAction = () => {
|
|
|
|
return typeof MessageTypes["message-" + props.message.type] !== "undefined";
|
|
|
|
};
|
|
|
|
|
|
|
|
return {
|
|
|
|
timeFormat,
|
|
|
|
messageTime,
|
|
|
|
messageTimeLocale,
|
|
|
|
messageComponent,
|
|
|
|
isAction,
|
|
|
|
};
|
2018-07-09 10:44:12 +00:00
|
|
|
},
|
2022-06-19 00:25:21 +00:00
|
|
|
});
|
2018-07-08 10:50:11 +00:00
|
|
|
</script>
|