Files
CT/src/View/Components/chatMessage.tsx
T

84 lines
3.2 KiB
TypeScript
Raw Normal View History

2024-07-21 01:12:35 +02:00
import * as React from "bloatless-react";
2024-07-23 13:09:46 +02:00
import { ChatMessageInfoModal } from "../Modals/chatMessageInfoModal";
2026-04-08 14:02:12 +00:00
import { ChatMessageStatuses } from "../../Model/Chat/chatModel";
2024-07-22 19:52:08 +02:00
import ChatMessageViewModel from "../../ViewModel/Chat/chatMessageViewModel";
import { MessageReactionButtonRow } from "./messageReactionButtonRow";
import CoreViewModel from "../../ViewModel/Global/coreViewModel";
import { InlineReply } from "./inlineReply";
import { ViewController } from "../viewController";
2024-07-21 01:12:35 +02:00
export function ChatMessage(
coreViewModel: CoreViewModel,
chatMessageViewModel: ChatMessageViewModel,
) {
2026-04-15 12:47:10 +00:00
const statusIcon = React.createProxyState(
2026-04-01 08:29:39 +00:00
[chatMessageViewModel.status],
() => {
switch (chatMessageViewModel.status.value) {
2026-04-08 14:02:12 +00:00
case ChatMessageStatuses.Outbox:
2026-04-01 08:29:39 +00:00
return "hourglass_top";
2026-04-08 14:02:12 +00:00
case ChatMessageStatuses.Sent:
2026-04-01 08:29:39 +00:00
return "check";
2026-04-08 14:02:12 +00:00
case ChatMessageStatuses.Received:
2026-04-01 08:29:39 +00:00
return "done_all";
default:
return "warning";
2024-07-21 13:13:41 +02:00
}
2026-04-15 12:47:10 +00:00
},
);
2024-07-21 13:13:41 +02:00
2026-04-01 08:29:39 +00:00
return (
<div
class="message-bubble"
id={chatMessageViewModel.chatMessage.id}
2026-04-01 08:29:39 +00:00
toggle:sentbyuser={chatMessageViewModel.sentByUser}
2026-04-11 21:01:23 +00:00
toggle:hidden={chatMessageViewModel.isHidden}
2026-04-01 08:29:39 +00:00
>
{InlineReply(chatMessageViewModel)}
2026-04-01 08:29:39 +00:00
<div class="main tile">
<div class="text-container">
<span class="sender-name ellipsis">
{chatMessageViewModel.sender}
</span>
<span
class="body"
subscribe:innerText={chatMessageViewModel.body}
></span>
<span class="timestamp ellipsis">
<span
class="icon"
subscribe:innerText={statusIcon}
></span>
{chatMessageViewModel.dateSent}
</span>
</div>
<div class="button-container">
<button
on:click={chatMessageViewModel.showInfoModal}
aria-label={
coreViewModel.translations.chatPage.message
2026-04-01 08:29:39 +00:00
.showMessageInfoButtonAudioLabel
}
>
<span class="icon">info</span>
</button>
<button
2026-04-14 13:21:57 +00:00
class="reply-button"
on:click={chatMessageViewModel.reply}
aria-label={
coreViewModel.translations.chatPage.message
.replyToMessageButton
}
>
<span class="icon">reply</span>
</button>
2026-04-01 08:29:39 +00:00
</div>
</div>
{MessageReactionButtonRow(coreViewModel, chatMessageViewModel)}
{ChatMessageInfoModal(coreViewModel, chatMessageViewModel)}
2026-04-01 08:29:39 +00:00
</div>
);
2024-07-21 01:12:35 +02:00
}