mirror of
https://github.com/block/buzz.git
synced 2026-08-18 06:50:31 +02:00
feat: add channel canvas frontend support (#130)
This commit is contained in:
@@ -3,6 +3,7 @@ import { invoke as tauriInvoke } from "@tauri-apps/api/core";
|
||||
import type {
|
||||
AddChannelMembersInput,
|
||||
AddChannelMembersResult,
|
||||
CanvasResponse,
|
||||
Channel,
|
||||
ChannelDetail,
|
||||
ChannelMember,
|
||||
@@ -23,6 +24,8 @@ import type {
|
||||
SearchMessagesInput,
|
||||
SearchMessagesResponse,
|
||||
SendChannelMessageResult,
|
||||
SetCanvasInput,
|
||||
SetCanvasResult,
|
||||
SetPresenceResult,
|
||||
SetChannelPurposeInput,
|
||||
SetChannelTopicInput,
|
||||
@@ -280,6 +283,17 @@ type RawManagedAgentPrereqs = {
|
||||
mcp: RawCommandAvailability;
|
||||
};
|
||||
|
||||
type RawCanvasResponse = {
|
||||
content: string | null;
|
||||
updated_at: number | null;
|
||||
author: string | null;
|
||||
};
|
||||
|
||||
type RawSetCanvasResult = {
|
||||
ok: boolean;
|
||||
event_id: string;
|
||||
};
|
||||
|
||||
function toTauriError(error: unknown): Error {
|
||||
if (error instanceof Error) {
|
||||
return error;
|
||||
@@ -588,6 +602,30 @@ export async function leaveChannel(channelId: string): Promise<void> {
|
||||
await invokeTauri("leave_channel", { channelId });
|
||||
}
|
||||
|
||||
export async function getCanvas(channelId: string): Promise<CanvasResponse> {
|
||||
const response = await invokeTauri<RawCanvasResponse>("get_canvas", {
|
||||
channelId,
|
||||
});
|
||||
return {
|
||||
content: response.content,
|
||||
updatedAt: response.updated_at,
|
||||
author: response.author,
|
||||
};
|
||||
}
|
||||
|
||||
export async function setCanvas(
|
||||
input: SetCanvasInput,
|
||||
): Promise<SetCanvasResult> {
|
||||
const response = await invokeTauri<RawSetCanvasResult>("set_canvas", {
|
||||
channelId: input.channelId,
|
||||
content: input.content,
|
||||
});
|
||||
return {
|
||||
ok: response.ok,
|
||||
eventId: response.event_id,
|
||||
};
|
||||
}
|
||||
|
||||
export async function getHomeFeed(
|
||||
input: GetHomeFeedInput = {},
|
||||
): Promise<HomeFeedResponse> {
|
||||
|
||||
@@ -65,6 +65,22 @@ export type SetChannelPurposeInput = {
|
||||
purpose: string;
|
||||
};
|
||||
|
||||
export type CanvasResponse = {
|
||||
content: string | null;
|
||||
updatedAt: number | null;
|
||||
author: string | null;
|
||||
};
|
||||
|
||||
export type SetCanvasInput = {
|
||||
channelId: string;
|
||||
content: string;
|
||||
};
|
||||
|
||||
export type SetCanvasResult = {
|
||||
ok: boolean;
|
||||
eventId: string;
|
||||
};
|
||||
|
||||
export type AddChannelMembersInput = {
|
||||
channelId: string;
|
||||
pubkeys: string[];
|
||||
|
||||
Reference in New Issue
Block a user