Show web chat messages in chat history

This commit is contained in:
James Lyne 2021-01-07 22:37:53 +00:00
parent 84c4f441c1
commit ac35a03e62
3 changed files with 13 additions and 12 deletions

View File

@ -445,7 +445,7 @@ function buildUpdates(data: Array<any>): DynmapUpdates {
} }
case 'chat': case 'chat':
if(!entry.account || !entry.message || !entry.timestamp) { if(!entry.message || !entry.timestamp) {
dropped.incomplete++; dropped.incomplete++;
continue; continue;
} }
@ -455,15 +455,16 @@ function buildUpdates(data: Array<any>): DynmapUpdates {
continue; continue;
} }
if(entry.source !== 'player') { if(entry.source !== 'player' && entry.source !== 'web') {
dropped.notImplemented++; dropped.notImplemented++;
continue; continue;
} }
updates.chat.push({ updates.chat.push({
type: 'chat', type: 'chat',
playerAccount: entry.account, source: entry.source || undefined,
playerName: entry.playerName || "", playerAccount: entry.account || undefined,
playerName: entry.playerName || undefined,
message: entry.message || "", message: entry.message || "",
timestamp: entry.timestamp, timestamp: entry.timestamp,
channel: entry.channel || undefined, channel: entry.channel || undefined,

View File

@ -16,7 +16,7 @@
<template> <template>
<li :class="`message message--${message.type}`"> <li :class="`message message--${message.type}`">
<img v-if="facesEnabled" width="16" height="16" class="message__face" :src="image" alt="" /> <img v-if="showFace" width="16" height="16" class="message__face" :src="image" alt="" />
<span v-if="showSender" class="message__sender" v-html="message.playerName"></span> <span v-if="showSender" class="message__sender" v-html="message.playerName"></span>
<span class="message__content" v-html="messageContent"></span> <span class="message__content" v-html="messageContent"></span>
</li> </li>
@ -40,7 +40,7 @@
setup(props) { setup(props) {
const store = useStore(); const store = useStore();
let image = ref(defaultImage), let image = ref(defaultImage),
facesEnabled = computed(() => store.state.components.chatBox?.showPlayerFaces), showFace = computed(() => store.state.components.chatBox?.showPlayerFaces && props.message.playerAccount),
showSender = computed(() => props.message.playerName && props.message.type === 'chat'), showSender = computed(() => props.message.playerName && props.message.type === 'chat'),
messageContent = computed(() => { messageContent = computed(() => {
switch(props.message.type) { switch(props.message.type) {
@ -64,15 +64,15 @@
}) })
onMounted(() => { onMounted(() => {
if(store.state.components.playerMarkers && store.state.components.playerMarkers.showSkinFaces) { if(showFace.value) {
Util.getMinecraftHead(props.message.playerAccount, '16') Util.getMinecraftHead(props.message.playerAccount as string, '16')
.then((result) => image.value = result.src).catch(() => {}); .then((result) => image.value = result.src).catch(() => {});
} }
}); });
return { return {
image, image,
facesEnabled, showFace,
showSender, showSender,
messageContent messageContent
} }

6
src/dynmap.d.ts vendored
View File

@ -302,11 +302,11 @@ interface DynmapParsedUrl {
interface DynmapChat { interface DynmapChat {
type: 'chat' | 'playerjoin' | 'playerleave'; type: 'chat' | 'playerjoin' | 'playerleave';
playerAccount: string; playerAccount?: string;
playerName: string; playerName?: string;
channel?: string; channel?: string;
message?: string; message?: string;
// source?: string; source?: string;
timestamp: number; timestamp: number;
} }