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

31 lines
844 B
TypeScript
Raw Normal View History

2026-09-22 21:57:22 +02:00
import * as React from "../../react";
2026-04-18 11:55:01 +00:00
import { RibbonButton } from "./ribbonButton";
2024-07-23 15:41:03 +02:00
import ChatViewModel, {
2026-04-08 14:02:12 +00:00
ChatPageTypes,
2024-07-23 15:41:03 +02:00
} from "../../ViewModel/Chat/chatViewModel";
2024-07-20 16:28:00 +02:00
export function ChatViewToggleButton(
2026-04-01 08:29:39 +00:00
label: string,
icon: string,
2026-04-08 14:02:12 +00:00
page: ChatPageTypes,
2026-04-01 08:29:39 +00:00
chatViewModel: ChatViewModel,
2024-07-20 16:28:00 +02:00
) {
2026-04-01 08:29:39 +00:00
function select() {
2026-04-13 19:45:52 +00:00
chatViewModel.openPage(page);
2026-04-01 08:29:39 +00:00
}
2024-07-20 16:28:00 +02:00
2026-04-01 08:29:39 +00:00
const isSelected = React.createProxyState(
[chatViewModel.selectedPage],
() => chatViewModel.selectedPage.value == page,
);
2024-07-20 16:28:00 +02:00
const isHighlighted = new React.State(false);
2026-04-08 14:02:12 +00:00
if (page == ChatPageTypes.Messages) {
chatViewModel.hasUnreadMessages.subscribe(
(hasUnreadMessages) => (isHighlighted.value = hasUnreadMessages),
);
}
return RibbonButton(label, icon, isSelected, select, isHighlighted);
2024-07-20 16:28:00 +02:00
}