Files
CT/src/Tabs/messageTab.tsx
T

60 lines
1.7 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-09 17:23:29 +02:00
import { ChatOptionModal } from "../Views/chatOptionModal";
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;
2024-07-09 17:23:29 +02:00
const isShowingOptions = new React.State(false);
2024-07-09 14:28:13 +02:00
2024-07-09 17:23:29 +02:00
function showOptions() {
isShowingOptions.value = true;
}
function hideOptions() {
isShowingOptions.value = false;
2024-07-09 14:28:13 +02:00
}
return (
2024-07-09 17:35:32 +02:00
<div>
2024-07-09 14:28:13 +02:00
<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>
2024-07-09 17:23:29 +02:00
<span subscribe:innerText={chat.primaryChannel}></span>
2024-07-09 14:28:13 +02:00
</span>
<span>
<button
2024-07-09 17:23:29 +02:00
aria-label={translation.showChatOptions}
on:click={showOptions}
2024-07-09 14:28:13 +02:00
>
2024-07-09 17:23:29 +02:00
<span class="icon">tune</span>
2024-07-09 14:28:13 +02:00
</button>
</span>
</header>
2024-07-09 17:35:32 +02:00
2024-07-09 14:28:13 +02:00
{ThreadView(chat)}
2024-07-09 17:35:32 +02:00
2024-07-09 14:28:13 +02:00
<footer>{MessageComposer(chat)}</footer>
2024-07-09 17:23:29 +02:00
{ChatOptionModal(chat, isShowingOptions)}
2024-07-09 17:35:32 +02:00
</div>
2024-07-09 14:28:13 +02:00
);
});
2024-07-09 17:35:32 +02:00
return <article id="message-tab" children:set={messageTabContent}></article>;
2024-07-07 22:11:18 +02:00
}