Files
CT/src/Tabs/messageTab.tsx
T

51 lines
1.5 KiB
TypeScript
Raw Normal View History

2024-07-07 22:11:18 +02:00
import * as React from "bloatless-react";
2024-07-09 15:15:17 +02:00
import { closeChatView, selectedChat } from "../Model/model";
2024-07-09 14:28:13 +02:00
2024-07-07 22:11:18 +02:00
import { MessageComposer } from "../Views/messageComposer";
import { ThreadView } from "../Views/threadView";
import { translation } from "../translations";
export function MessageTab() {
2024-07-09 14:28:13 +02:00
const messageTabContent = React.createProxyState([selectedChat], () => {
if (selectedChat.value == undefined)
return (
<div class="width-100 height-100 flex-column align-center justify-center">
<span class="secondary">{translation.noChatSelected}</span>
</div>
);
const chat = selectedChat.value;
function clearMessageHistory() {
chat.clearMessages();
}
return (
<article id="message-tab">
<header class="padding-0">
<span class="flex-row align-center">
2024-07-09 15:15:17 +02:00
<button aria-label={translation.back} on:click={closeChatView}>
2024-07-09 14:28:13 +02:00
<span class="icon">arrow_back</span>
</button>
<span subscribe:innerText={chat.currentChannel}></span>
</span>
<span>
<button
aria-label={translation.clearHistory}
on:click={clearMessageHistory}
>
<span class="icon">delete_sweep</span>
</button>
</span>
</header>
{ThreadView(chat)}
<footer>{MessageComposer(chat)}</footer>
</article>
);
});
return <div children:set={messageTabContent}></div>;
2024-07-07 22:11:18 +02:00
}