2024-07-07 22:11:18 +02:00
|
|
|
import * as React from "bloatless-react";
|
|
|
|
|
|
2024-07-09 14:11:20 +02:00
|
|
|
import { Chat, ChatMessage } from "../Model/chatModel";
|
2024-07-08 12:34:37 +02:00
|
|
|
|
|
|
|
|
import { translation } from "../translations";
|
2024-07-07 22:11:18 +02:00
|
|
|
|
2024-07-09 14:28:13 +02:00
|
|
|
export function ThreadView(chat: Chat) {
|
|
|
|
|
const messageConverter: React.ListItemConverter<ChatMessage> = (message) => {
|
|
|
|
|
function copyMessage() {
|
|
|
|
|
navigator.clipboard.writeText(message.body);
|
|
|
|
|
}
|
2024-07-08 12:50:54 +02:00
|
|
|
|
2024-07-09 14:28:13 +02:00
|
|
|
function decrypt() {
|
|
|
|
|
chat.decryptReceivedMessage(message);
|
|
|
|
|
}
|
2024-07-08 12:34:37 +02:00
|
|
|
|
2024-07-09 14:28:13 +02:00
|
|
|
function remove() {
|
|
|
|
|
chat.deleteMessage(message);
|
|
|
|
|
}
|
2024-07-08 12:50:54 +02:00
|
|
|
|
2024-07-09 14:28:13 +02:00
|
|
|
return (
|
|
|
|
|
<div class="tile width-100 flex-no padding-0">
|
|
|
|
|
<div class="flex-column">
|
|
|
|
|
<div class="flex-row justify-apart align-center secondary">
|
|
|
|
|
<span class="padding-h ellipsis">
|
|
|
|
|
<b class="info">{message.sender}</b> - {message.channel}
|
|
|
|
|
</span>
|
|
|
|
|
<span class="flex-row">
|
|
|
|
|
<button
|
|
|
|
|
aria-label={translation.copyMessage}
|
|
|
|
|
on:click={copyMessage}
|
|
|
|
|
>
|
|
|
|
|
<span class="icon">content_copy</span>
|
|
|
|
|
</button>
|
|
|
|
|
<button
|
|
|
|
|
aria-label={translation.decryptMessage}
|
|
|
|
|
on:click={decrypt}
|
|
|
|
|
>
|
|
|
|
|
<span class="icon">key</span>
|
|
|
|
|
</button>
|
|
|
|
|
<button aria-label={translation.deleteMessage} on:click={remove}>
|
|
|
|
|
<span class="icon">delete</span>
|
|
|
|
|
</button>
|
|
|
|
|
</span>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="flex-column padding-h padding-bottom">
|
2024-07-09 17:23:29 +02:00
|
|
|
<b class="break-word">{message.body}</b>
|
2024-07-09 14:28:13 +02:00
|
|
|
<span class="secondary">
|
|
|
|
|
{new Date(message.isoDate).toLocaleString()}
|
|
|
|
|
</span>
|
2024-07-09 14:11:20 +02:00
|
|
|
</div>
|
2024-07-08 12:34:37 +02:00
|
|
|
</div>
|
2024-07-09 14:28:13 +02:00
|
|
|
</div>
|
2024-07-09 14:11:20 +02:00
|
|
|
);
|
2024-07-09 14:28:13 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<div
|
|
|
|
|
class="flex-column gap"
|
|
|
|
|
children:append={[chat.messages, messageConverter]}
|
|
|
|
|
></div>
|
|
|
|
|
);
|
2024-07-07 22:11:18 +02:00
|
|
|
}
|