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
+19 -8
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: {
+8
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;