feat: add channel creation flow (#8)

This commit is contained in:
Wes
2026-03-09 17:33:13 -07:00
committed by GitHub
parent 774bd62fb3
commit 6f900bcbcc
16 changed files with 582 additions and 78 deletions

View File

@@ -3,6 +3,7 @@ import { invoke } from "@tauri-apps/api/core";
import type {
Channel,
ChannelType,
CreateChannelInput,
Identity,
RelayEvent,
} from "@/shared/api/types";
@@ -21,6 +22,17 @@ type RawChannel = {
participant_pubkeys: string[];
};
function fromRawChannel(channel: RawChannel): Channel {
return {
id: channel.id,
name: channel.name,
channelType: channel.channel_type,
description: channel.description,
participants: channel.participants,
participantPubkeys: channel.participant_pubkeys,
};
}
export async function getIdentity(): Promise<Identity> {
const identity = await invoke<RawIdentity>("get_identity");
@@ -36,15 +48,14 @@ export function getRelayWsUrl(): Promise<string> {
export async function getChannels(): Promise<Channel[]> {
const channels = await invoke<RawChannel[]>("get_channels");
return channels.map(fromRawChannel);
}
return channels.map((channel) => ({
id: channel.id,
name: channel.name,
channelType: channel.channel_type,
description: channel.description,
participants: channel.participants,
participantPubkeys: channel.participant_pubkeys,
}));
export async function createChannel(
input: CreateChannelInput,
): Promise<Channel> {
const channel = await invoke<RawChannel>("create_channel", input);
return fromRawChannel(channel);
}
export async function signRelayEvent(input: {

View File

@@ -1,4 +1,5 @@
export type ChannelType = "stream" | "forum" | "dm";
export type ChannelVisibility = "open" | "private";
export type Channel = {
id: string;
@@ -9,6 +10,13 @@ export type Channel = {
participantPubkeys: string[];
};
export type CreateChannelInput = {
name: string;
channelType: Exclude<ChannelType, "dm">;
visibility: ChannelVisibility;
description?: string;
};
export type Identity = {
pubkey: string;
displayName: string;

View File

@@ -7,6 +7,7 @@ import { cn } from "@/shared/lib/cn";
type MarkdownProps = {
className?: string;
compact?: boolean;
content: string;
};
@@ -121,7 +122,11 @@ const markdownComponents: Components = {
),
};
export function Markdown({ className, content }: MarkdownProps) {
export function Markdown({
className,
compact = false,
content,
}: MarkdownProps) {
let processedContent = content;
if (/^(?:\s{2}\n)+/.test(content)) {
@@ -135,7 +140,9 @@ export function Markdown({ className, content }: MarkdownProps) {
return (
<div
className={cn(
"max-w-none break-words text-sm leading-7 text-foreground/90 [&>*:first-child]:mt-0 [&>*:last-child]:mb-0 [&>*]:my-3",
compact
? "max-w-none break-words text-[15px] leading-6 text-foreground/90 [&>*:first-child]:mt-0 [&>*:last-child]:mb-0 [&>*]:my-1.5"
: "max-w-none break-words text-sm leading-7 text-foreground/90 [&>*:first-child]:mt-0 [&>*:last-child]:mb-0 [&>*]:my-3",
className,
)}
>