Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

use-thread-detail.ts

26 lines831 Bytes

1import type { EnvironmentId, ThreadId } from "@t3tools/contracts";
2import * as Option from "effect/Option";
3​
4import { useEnvironmentThread } from "./threads";
5import { useThreadSelection } from "./use-thread-selection";
6​
7export interface ThreadDetailTarget {
8 readonly environmentId: EnvironmentId | null;
9 readonly threadId: ThreadId | null;
11​
12export function useThreadDetail(target: ThreadDetailTarget) {
13 return useEnvironmentThread(target.environmentId, target.threadId);
15​
16/**
17 * The selection owns the subscription so it can hold it back while a queued
18 * creation has not reached the server yet.
19 */
20export function useSelectedThreadDetailState() {
21 return useThreadSelection().selectedThreadDetailState;
23​
24export function useSelectedThreadDetail() {
25 return Option.getOrNull(useSelectedThreadDetailState().data);