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

View File

@ -16,7 +16,7 @@
<template>
<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 class="message__content" v-html="messageContent"></span>
</li>
@ -40,7 +40,7 @@
setup(props) {
const store = useStore();
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'),
messageContent = computed(() => {
switch(props.message.type) {
@ -64,15 +64,15 @@
})
onMounted(() => {
if(store.state.components.playerMarkers && store.state.components.playerMarkers.showSkinFaces) {
Util.getMinecraftHead(props.message.playerAccount, '16')
if(showFace.value) {
Util.getMinecraftHead(props.message.playerAccount as string, '16')
.then((result) => image.value = result.src).catch(() => {});
}
});
return {
image,
facesEnabled,
showFace,
showSender,
messageContent
}

6
src/dynmap.d.ts vendored
View File

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