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