mirror of
https://github.com/block/buzz.git
synced 2026-08-18 06:50:31 +02:00
Add multi-workspace support to desktop app (#409)
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -30,19 +30,19 @@ export class RelayClient {
|
||||
private wsId: number | null = null;
|
||||
private relayUrl: string | null = null;
|
||||
private connectPromise: Promise<void> | null = null;
|
||||
private reconnectTimeout: ReturnType<typeof setTimeout> | null = null;
|
||||
private reconnectTimeout: number | null = null;
|
||||
private reconnectDelayMs = RECONNECT_BASE_DELAY_MS;
|
||||
private keepAliveRequested = false;
|
||||
private authRequest: {
|
||||
pendingEventId: string;
|
||||
resolve: () => void;
|
||||
reject: (error: Error) => void;
|
||||
timeout: ReturnType<typeof setTimeout>;
|
||||
timeout: number;
|
||||
} | null = null;
|
||||
private subscriptions = new Map<string, RelaySubscription>();
|
||||
private pendingEvents = new Map<string, PendingEvent>();
|
||||
private eventBuffer: Array<{ subId: string; event: RelayEvent }> = [];
|
||||
private flushTimeout: ReturnType<typeof setTimeout> | null = null;
|
||||
private flushTimeout: number | null = null;
|
||||
private reconnectListeners = new Set<() => void>();
|
||||
private hasConnectedOnce = false;
|
||||
private notifyReconnectListeners = false;
|
||||
|
||||
@@ -12,7 +12,7 @@ type HistorySubscription = {
|
||||
events: RelayEvent[];
|
||||
resolve: (events: RelayEvent[]) => void;
|
||||
reject: (error: Error) => void;
|
||||
timeout: ReturnType<typeof setTimeout>;
|
||||
timeout: number;
|
||||
};
|
||||
|
||||
type LiveSubscription = {
|
||||
@@ -27,7 +27,7 @@ export type PendingEvent = {
|
||||
event: RelayEvent;
|
||||
resolve: (event: RelayEvent) => void;
|
||||
reject: (error: Error) => void;
|
||||
timeout: ReturnType<typeof setTimeout>;
|
||||
timeout: number;
|
||||
};
|
||||
|
||||
export type RelaySubscription = HistorySubscription | LiveSubscription;
|
||||
|
||||
@@ -528,6 +528,10 @@ export async function setPresence(
|
||||
};
|
||||
}
|
||||
|
||||
export function getDefaultRelayUrl(): Promise<string> {
|
||||
return invokeTauri<string>("get_default_relay_url");
|
||||
}
|
||||
|
||||
export function getRelayWsUrl(): Promise<string> {
|
||||
return invokeTauri<string>("get_relay_ws_url");
|
||||
}
|
||||
@@ -1106,3 +1110,15 @@ export async function confirmPairingSas(): Promise<void> {
|
||||
export async function cancelPairing(): Promise<void> {
|
||||
await invokeTauri("cancel_pairing");
|
||||
}
|
||||
|
||||
export async function applyWorkspace(
|
||||
relayUrl: string,
|
||||
nsec?: string,
|
||||
token?: string,
|
||||
): Promise<void> {
|
||||
await invokeTauri("apply_workspace", {
|
||||
relayUrl,
|
||||
nsec: nsec ?? null,
|
||||
token: token ?? null,
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user