352 lines
23 KiB
TypeScript
352 lines
23 KiB
TypeScript
import { useEffect, useId, useRef, useState } from "react";
|
|
import { Btn, SwitchItem } from "../../components/living/primitives";
|
|
import { NumberControl } from "../../components/living/NumberControl";
|
|
import { Glyph } from "../../ui/icons";
|
|
import { useCopy } from "../../ui/copy";
|
|
import { downloadBlob } from "../../lib/download";
|
|
import { formatChatTranscript } from "../../lib/room-chat-export";
|
|
import type { ChannelMessage, ChannelUser, ChannelRoom, RoomCreationPolicy } from "../protocol";
|
|
import { MAX_RELAY_CAPACITY } from "../protocol";
|
|
import { RoomCreationInterrupted, roomCreationPolicyFor, roomDraft, roomSettings, roomSettingsPatch, type RoomDraft } from "../room-creation";
|
|
import type { ChannelController } from "../types";
|
|
import { ChannelAction } from "./ChannelAction";
|
|
import { ChannelSettingsDialog, ChannelSettingsTabs, useSettingsAction, type SettingsAction } from "./ChannelSettingsDialog";
|
|
import { ChannelIdentityFields } from "./ChannelIdentity";
|
|
import "./channel-room-controls.css";
|
|
import { BackupControls, RoomRestoreResult } from "./BackupControls";
|
|
import { roomRestoreRecovery, type RoomRestoreRecovery } from "../hosting-api";
|
|
import { messageAuthorName, userProfile } from "../presentation";
|
|
import { fileSize, type AttachmentLimits } from "../attachments";
|
|
|
|
export function RoomChatExport({ messages, users }: { messages: readonly ChannelMessage[]; users: readonly Pick<ChannelUser, "id" | "name">[] }) {
|
|
const { t } = useCopy();
|
|
const hasText = messages.some(message => message.text);
|
|
return <section className="c3-room-transcript" aria-label={t("room.chat.title")}>
|
|
<p>{t("room.chat.exportNote")}</p>
|
|
{messages.length === 0 && <p role="status">{t("room.chat.nothingLoaded")}</p>}
|
|
<ChannelAction icon="save" quiet label={t("room.chat.export")}
|
|
disabled={!hasText} onClick={() => {
|
|
const text = formatChatTranscript(messages.filter(message => message.text).map(message => ({
|
|
occurredAt: message.time,
|
|
sender: { displayName: messageAuthorName(message, users, t("room.common.user")) },
|
|
payload: { kind: "chat" as const, text: message.text },
|
|
})));
|
|
downloadBlob(new Blob([text], { type: "text/plain;charset=utf-8" }),
|
|
`piik-chat-${new Date().toISOString().replace(/[:.]/g, "-")}.txt`);
|
|
}} />
|
|
</section>;
|
|
}
|
|
|
|
function RelayLimit({ value, min, label, caption = label, note, disabled, onChange }: {
|
|
value: number; min: number; label: string; caption?: string; note: string; disabled: boolean; onChange(value: number): void;
|
|
}) {
|
|
const { t } = useCopy();
|
|
return <NumberControl value={value} min={min} max={MAX_RELAY_CAPACITY} step={1} unit={t(value === 1 ? "room.relay.route" : "room.relay.routes")}
|
|
name="relay-capacity" label={label} disabled={disabled} onChange={onChange} className="lr-door-group c3-relay-limit">
|
|
{input => <><div className="lr-quality-heading"><span className="lr-door-glyph"><Glyph name="branch" size={18} />
|
|
<span>{caption}</span></span>{input}</div>
|
|
<p>{note}</p></>}
|
|
</NumberControl>;
|
|
}
|
|
|
|
export function ServiceTransit({ channel, room, disabled, run }: { channel: ChannelController; room: ChannelRoom; disabled: boolean; run: SettingsAction }) {
|
|
const { t } = useCopy();
|
|
const relay = room.serviceRelay;
|
|
if (!room.canManage || !room.authorized || !room.available || !relay) return null;
|
|
return <section className="c3-room-relay">
|
|
<h4>{t("room.transit.title")}</h4>
|
|
<SwitchItem checked={relay.enabled} disabled={disabled || channel.pending.has(`room:${room.id}`)}
|
|
label={t("room.transit.allow")} onChange={enabled => { void run(() => channel.updateRoom(room.id, { allowServiceRelay: enabled }, false)); }} />
|
|
<p>{t("room.transit.note")}</p>
|
|
{!relay.available && <p role="status">{t("room.transit.unavailable")}</p>}
|
|
</section>;
|
|
}
|
|
|
|
export function RoomForm({ room, value, onChange, roomHost, inviteOnly, disabled, busy, onSave, onCancel, createLabel }: {
|
|
room?: ChannelRoom; value: RoomDraft; onChange(value: Partial<RoomDraft>): void; roomHost?: "server" | "app" | "browser"; disabled: boolean; busy: boolean;
|
|
inviteOnly: boolean;
|
|
onSave: () => Promise<unknown>; onCancel(): void; createLabel?: string;
|
|
}) {
|
|
const { t } = useCopy();
|
|
const { name, icon, access, hidden, password, removePassword, relayCapacity } = value;
|
|
const change = onChange;
|
|
const [imageBusy, setImageBusy] = useState(false);
|
|
return <form className="c3-room-form" onSubmit={event => {
|
|
event.preventDefault();
|
|
if (!name.trim() || disabled || imageBusy) return;
|
|
void onSave();
|
|
}} onKeyDown={event => { if (event.key === "Enter" && event.nativeEvent.isComposing) event.preventDefault(); }}>
|
|
{roomHost && <p>{roomHost === "server" ? t("room.create.serverHostedNote")
|
|
: roomHost === "app" ? t("room.create.appHostedNote") : t("room.create.browserHostedNote")}</p>}
|
|
<ChannelIdentityFields name={name} icon={icon} label={t("room.settings.name")}
|
|
roomPicture={{ value: value.picture === undefined ? room?.picture ?? null : value.picture, onChange: picture => change({ picture }) }}
|
|
disabled={disabled} onName={name => change({ name })} onIcon={icon => change({ icon })} imageBusy={imageBusy} onImageBusyChange={setImageBusy} />
|
|
{inviteOnly ? <p>{t("room.settings.inviteOnlyNote")}</p> : <>
|
|
<fieldset className="lr-toggle c3-room-access" disabled={disabled}>
|
|
<legend className="visually-hidden">{t("room.settings.admission")}</legend>
|
|
{(["public", "private"] as const).map(value => <label key={value}>
|
|
<input type="radio" name="access" value={value} checked={access === value}
|
|
onChange={() => change({ access: value, password: "", removePassword: false })} />
|
|
<span><Glyph name={value === "public" ? "users" : "lock"} size={18} />
|
|
{value === "public" ? t("room.settings.public") : t("room.settings.private")}</span>
|
|
</label>)}
|
|
</fieldset>
|
|
<p>{access === "public" ? t("room.settings.publicNote")
|
|
: t("room.settings.privateNote")}</p>
|
|
{access === "private" && <div className="c3-private-options">
|
|
<label><span>{t("room.settings.optionalPassword")}</span><input className="c3-input" type="password"
|
|
maxLength={128} autoComplete="new-password" value={password} disabled={disabled || removePassword}
|
|
placeholder={room?.hasPassword ? t("room.settings.keepPassword") : undefined}
|
|
onChange={event => change({ password: event.target.value })} /></label>
|
|
{room?.hasPassword && <label className="c3-check"><input type="checkbox" checked={removePassword} disabled={disabled}
|
|
onChange={event => { change({ removePassword: event.target.checked, password: "" }); }} />{t("room.settings.removePassword")}</label>}
|
|
<label className="c3-check"><input type="checkbox" checked={hidden} disabled={disabled} onChange={event => change({ hidden: event.target.checked })} />
|
|
{t("room.settings.hidden")}</label>
|
|
</div>}
|
|
</>}
|
|
<details className="c3-settings-details"><summary>{t("room.relay.default")}</summary>
|
|
<RelayLimit value={relayCapacity} min={1} label={t("room.relay.defaultLimit")}
|
|
note={t("room.relay.defaultNote")}
|
|
disabled={disabled} onChange={relayCapacity => change({ relayCapacity })} /></details>
|
|
<div className="c3-form-actions"><ChannelAction icon="x" quiet label={t("room.action.cancel")} onClick={onCancel} />
|
|
<ChannelAction icon={room ? "check" : "plus"} label={room ? t("room.action.save") : createLabel ?? t("room.action.create")}
|
|
primary type="submit" disabled={disabled || imageBusy || !name.trim()} busy={busy} /></div>
|
|
</form>;
|
|
}
|
|
|
|
/** Creation and management share the same form and modal surface. */
|
|
export function ChannelRoomCreateDialog({ channel, initialName = "", initialInterruption = null, creationPolicy, onCreated, onClose }: {
|
|
channel: ChannelController; initialName?: string; initialInterruption?: RoomCreationInterrupted | null; creationPolicy: RoomCreationPolicy; onCreated(id: string): void; onClose(): void;
|
|
}) {
|
|
const { t } = useCopy();
|
|
const { error, run } = useSettingsAction();
|
|
const [draft, setDraft] = useState<RoomDraft>(() => ({ ...roomDraft(), name: initialName }));
|
|
const input = useRef<HTMLInputElement>(null);
|
|
const [copy, setCopy] = useState<{ file: File; retainedFileCount: number } | null>(null), [inspecting, setInspecting] = useState(false);
|
|
const [completed, setCompleted] = useState<"uncached" | "restored-uncached" | RoomRestoreRecovery | RoomCreationInterrupted | null>(initialInterruption);
|
|
const interrupted = completed instanceof RoomCreationInterrupted ? completed : null;
|
|
const [creating, setCreating] = useState(false);
|
|
const connected = channel.connection === "connected";
|
|
const inviteOnly = creationPolicy === "invite_only";
|
|
const serverHosted = channel.state?.channel.hostingMode === "hosted";
|
|
const roomHost = serverHosted ? "server" : channel.appConnected ? "app" : "browser";
|
|
const busy = channel.pending.has("create-room");
|
|
const backupBusy = channel.pending.has("room-backup");
|
|
const title = t("room.action.create");
|
|
const interruptedRoomId = interrupted?.roomId;
|
|
const recovered = interruptedRoomId && connected && channel.state?.channel.rooms.some(room =>
|
|
room.id === interruptedRoomId && room.authorized && room.available);
|
|
return <ChannelSettingsDialog title={title} compact error={error} onClose={onClose}>
|
|
<div className="c3-settings-panels">
|
|
{interrupted ? <div className="c3-backup-confirm">
|
|
<p role="status">{t(recovered ? "room.create.recovered" : interrupted.committed
|
|
? "room.create.committedReconnect" : "room.create.unconfirmed")}</p>
|
|
{recovered && <ChannelAction icon="couch" primary label={t("room.create.openRecovered")} onClick={() => {
|
|
onCreated(interruptedRoomId);
|
|
onClose();
|
|
}} />}
|
|
</div> : completed ? <RoomRestoreResult onClose={onClose} unconfirmed={completed === "room_restore_unconfirmed"}
|
|
message={t(completed === "room_restore_unconfirmed" ? "channel.error.roomRestoreUnconfirmed"
|
|
: completed === "room_restored_connection_failed" ? "room.create.reconnect"
|
|
: completed === "restored-uncached" ? "room.create.restoredUncached" : "room.create.createdUncached")} />
|
|
: creationPolicy === "owner_only" ? <div className="c3-backup-confirm">
|
|
<p role="status">{t("channel.previewPage.ownerCreatesRooms")}</p>
|
|
<ChannelAction icon="x" quiet label={t("room.action.cancel")} onClick={onClose} />
|
|
</div> : <>
|
|
<section className="c3-room-copy-load">
|
|
<input ref={input} type="file" accept=".zip,application/zip" hidden onChange={event => {
|
|
const file = event.currentTarget.files?.[0]; event.currentTarget.value = "";
|
|
if (!file) return;
|
|
setInspecting(true);
|
|
void run(() => channel.inspectRoomCopy(file), ({ settings: info, retainedFileCount }) => {
|
|
setCopy({ file, retainedFileCount }); setDraft({ ...roomDraft(), ...info, name: info.name ?? initialName, icon: info.icon ?? "couch", access: "private", password: "", hidden: false });
|
|
}).finally(() => setInspecting(false));
|
|
}} />
|
|
<ChannelAction icon="arrowUp" quiet label={t("room.copy.load")}
|
|
disabled={!connected || busy || backupBusy || inspecting} busy={inspecting} onClick={() => input.current?.click()} />
|
|
{copy && <><p>{copy.file.name}</p><p>{t("room.copy.retainedFileCount", { count: String(copy.retainedFileCount) })}</p><p>{t("room.copy.loadNote")}</p>
|
|
<ChannelAction icon="x" quiet label={t("room.copy.remove")} disabled={busy || backupBusy} onClick={() => setCopy(null)} /></>}
|
|
</section>
|
|
<RoomForm value={draft} onChange={fields => setDraft(previous => ({ ...previous, ...fields }))} roomHost={roomHost} inviteOnly={inviteOnly}
|
|
disabled={!connected || busy || backupBusy || inspecting} busy={creating}
|
|
createLabel={copy ? t("room.copy.create") : undefined}
|
|
onCancel={onClose} onSave={() => { const settings = roomSettings(draft, inviteOnly); setCreating(true); return run(async () => {
|
|
try {
|
|
if (copy) return await channel.importRoomCopy(copy.file, settings);
|
|
return { roomId: await channel.createRoom(settings, false), cached: true };
|
|
}
|
|
catch (error) {
|
|
const recovery = error instanceof RoomCreationInterrupted ? error : copy && roomRestoreRecovery(error);
|
|
if (!recovery) throw error;
|
|
setCompleted(recovery);
|
|
return null;
|
|
}
|
|
}, result => { if (result) { onCreated(result.roomId); if (result.cached) onClose(); else setCompleted("uncached"); } }).finally(() => setCreating(false)); }} />
|
|
{!serverHosted && <details className="c3-settings-details"><summary>{t("room.backup.restore")}</summary>
|
|
{inviteOnly && <p>{t("room.backup.inviteOnlyNote")}</p>}
|
|
<BackupControls onClose={onClose} run={run} disabled={!connected || busy} busy={backupBusy} replacing={false}
|
|
onRecovery={setCompleted} onRestore={async file => {
|
|
const result = await channel.restoreRoomBackup(file);
|
|
onCreated(result.roomId);
|
|
if (result.cached) onClose(); else setCompleted("restored-uncached");
|
|
return result;
|
|
}} />
|
|
</details>}
|
|
</>}
|
|
</div>
|
|
</ChannelSettingsDialog>;
|
|
}
|
|
|
|
/** One dialog instance manages the requested room independently of room navigation. */
|
|
export function ChannelRoomSettingsDialog({ channel, room, onClose }: {
|
|
channel: ChannelController; room: ChannelRoom; onClose(): void;
|
|
}) {
|
|
return <RoomSettings key={room.id} channel={channel} room={room} onClose={onClose} />;
|
|
}
|
|
type RoomSettingsTask = "room" | "relay" | "data";
|
|
|
|
function RoomCopyExport({ channel, roomId, includeFiles, disabled, busy, run }: {
|
|
channel: ChannelController; roomId: string; includeFiles: boolean; disabled: boolean; busy: boolean; run: SettingsAction;
|
|
}) {
|
|
const { t } = useCopy();
|
|
const [includeRoomInfo, setIncludeRoomInfo] = useState(true);
|
|
const [exporting, setExporting] = useState(false);
|
|
return <section className="c3-backup-controls">
|
|
<h3>{t("room.copy.title")}</h3>
|
|
<p>{t("room.copy.exportNote")}</p>
|
|
<label className="c3-check"><input type="checkbox" checked={includeRoomInfo} disabled={disabled || busy}
|
|
onChange={event => setIncludeRoomInfo(event.target.checked)} />
|
|
{t("room.copy.includeSettings")}</label>
|
|
<ChannelAction icon="save" quiet label={t("room.copy.export")} disabled={disabled || busy} busy={exporting}
|
|
onClick={() => { setExporting(true); void run(async () => downloadBlob(await channel.exportRoomCopy(roomId, includeRoomInfo, includeFiles), "piik-room-copy.zip"))
|
|
.finally(() => setExporting(false)); }} />
|
|
</section>;
|
|
}
|
|
|
|
function RoomSettings({ channel, room, onClose }: {
|
|
channel: ChannelController; room: ChannelRoom; onClose(): void;
|
|
}) {
|
|
const { t } = useCopy();
|
|
const id = useId();
|
|
const { error, run } = useSettingsAction();
|
|
const [draft, setDraft] = useState<Partial<RoomDraft>>({});
|
|
const [task, setTask] = useState<RoomSettingsTask>(room.canManage ? "room" : "relay");
|
|
const [backupAvailable, setBackupAvailable] = useState(false);
|
|
const [includeFiles, setIncludeFiles] = useState(true);
|
|
const [fileLimits, setFileLimits] = useState<AttachmentLimits | null>(null);
|
|
useEffect(() => {
|
|
let current = true; setBackupAvailable(false); setFileLimits(null);
|
|
if (room.canManage) void channel.roomBackupAvailable(room.id).then(value => {
|
|
if (!current) return;
|
|
setBackupAvailable(value);
|
|
if (value) void channel.attachments.limits().then(limits => { if (current) setFileLimits(limits); }).catch(() => {});
|
|
});
|
|
return () => { current = false; };
|
|
}, [room.id, room.canManage, room.delivery?.bindingId, channel.sessionId, channel.appConnected, channel.connection, channel.roomBackupAvailable, channel.attachments]);
|
|
const connected = channel.connection === "connected";
|
|
const site = channel.state?.channel;
|
|
const serverHosted = site?.hostingMode === "hosted";
|
|
const deleteData = serverHosted || room.available;
|
|
const canPurge = room.authorized && (room.canManage || (!!channel.self && channel.self.id === site?.ownerId));
|
|
const inviteOnly = !!site && roomCreationPolicyFor(site, room.creatorId) === "invite_only";
|
|
const available = connected && room.available;
|
|
const busy = channel.pending.has(`room:${room.id}`);
|
|
const backupBusy = channel.pending.has("room-backup");
|
|
const removing = channel.pending.has(`delete:${room.id}`);
|
|
const purging = channel.pending.has(`clear-history:${room.id}`);
|
|
const clearingCache = channel.pending.has(`clear-local-cache:${room.id}`);
|
|
const working = busy || backupBusy || removing;
|
|
const members = room.members?.filter(userId => userId !== room.creatorId) ?? [];
|
|
const [membersError, setMembersError] = useState(false);
|
|
useEffect(() => {
|
|
let current = true; setMembersError(false);
|
|
if (room.canManage && room.members?.length) void channel.loadProfiles(room.members).catch(() => { if (current) setMembersError(true); });
|
|
return () => { current = false; };
|
|
}, [room.id, room.members, room.canManage, channel.loadProfiles, channel.connection]);
|
|
const tasks = [
|
|
...(room.canManage ? [{ value: "room", label: t("room.settings.roomTab"), icon: "couch" } as const] : []),
|
|
...(room.authorized && room.canManage ? [{ value: "relay", label: t("room.settings.connectionTab"), icon: "branch" } as const] : []),
|
|
...(room.authorized || room.canManage ? [{ value: "data", label: t("room.settings.recordsTab"), icon: "save" } as const] : []),
|
|
];
|
|
const selected = tasks.some(value => value.value === task) ? task : tasks[0]?.value;
|
|
return <ChannelSettingsDialog title={room.name} caption={t("room.settings.title")} error={error} onClose={onClose}>
|
|
<div className="c3-settings-body">
|
|
<ChannelSettingsTabs<RoomSettingsTask> id={id} label={t("room.settings.title")} tasks={tasks} selected={selected ?? "room"} onSelect={setTask} />
|
|
<div className="c3-settings-panels">
|
|
{!room.available && <p className="c3-settings-offline">{room.canManage ? t(serverHosted ? "room.settings.offlineHostedManager" : "room.settings.offlineManager")
|
|
: t("room.settings.offlineRelay")}</p>}
|
|
{room.canManage && <section id={`${id}-room`} role="tabpanel" aria-labelledby={`${id}-room-tab`} hidden={selected !== "room"}>
|
|
<RoomForm room={room} value={{ ...roomDraft(room), ...draft }} onChange={fields => setDraft(previous => ({ ...previous, ...fields }))}
|
|
inviteOnly={inviteOnly} disabled={!available || working} busy={busy}
|
|
onCancel={onClose} onSave={() => {
|
|
const changes = roomSettingsPatch(draft, inviteOnly ? room : undefined);
|
|
return Object.keys(changes).length ? run(() => channel.updateRoom(room.id, changes, false), onClose) : Promise.resolve(onClose());
|
|
}} />
|
|
{room.access === "private" && members.length > 0 && <details className="c3-room-members">
|
|
<summary>{t("room.settings.members")}</summary>
|
|
{members.map(userId =>
|
|
<div key={userId}><span>{userProfile(channel.state, channel.profiles, userId)?.name ?? t("room.common.user")}</span>
|
|
<ChannelAction icon="x" quiet iconOnly danger label={t("room.settings.revokeAccess")} hint="hint-close"
|
|
busy={channel.pending.has(`revoke:${room.id}:${userId}`)} disabled={!available || working}
|
|
onClick={() => { void run(() => channel.revokeRoomAccess(room.id, userId, false)); }} /></div>)}
|
|
{membersError && <p role="status">{t("room.settings.profilesFailed")}</p>}
|
|
</details>}
|
|
<section className="c3-room-removal">
|
|
<Btn icon="x" size="dense" quiet tone="danger" busy={removing} disabled={!connected || working}
|
|
title={{ text: t(deleteData ? "room.action.delete" : "room.action.remove") }}
|
|
cap={{ text: t(deleteData ? "room.action.delete" : "room.action.remove") }}
|
|
onClick={() => {
|
|
const question = t(serverHosted ? "room.settings.confirmHostedDelete" :
|
|
deleteData ? "room.settings.confirmDelete" : "room.settings.confirmRemove", { name: room.name });
|
|
if (window.confirm(question)) void run(() => channel.deleteRoom(room.id, deleteData, false), onClose);
|
|
}} />
|
|
</section>
|
|
</section>}
|
|
{room.authorized && room.canManage && <section id={`${id}-relay`} role="tabpanel" aria-labelledby={`${id}-relay-tab`} hidden={selected !== "relay"}>
|
|
<ServiceTransit channel={channel} room={room} disabled={!available || working} run={run} />
|
|
</section>}
|
|
{(room.authorized || room.canManage) && <section id={`${id}-data`} role="tabpanel" aria-labelledby={`${id}-data-tab`} hidden={selected !== "data"}>
|
|
<h3>{t("room.settings.recordsTitle")}</h3>
|
|
{room.authorized && <RoomChatExport messages={channel.messagesByRoom[room.id] ?? []} users={[...(channel.state?.users ?? []), ...channel.profiles.values()]} />}
|
|
{room.authorized && <section className="c3-backup-controls">
|
|
<p>{t("room.settings.localCacheScope")}</p>
|
|
<ChannelAction icon="x" quiet label={t("room.settings.clearLocalCache")} busy={clearingCache} disabled={working || purging || clearingCache}
|
|
onClick={() => {
|
|
if (window.confirm(t("room.settings.confirmClearLocalCache", { name: room.name })))
|
|
void run(() => channel.clearLocalRoomCache(room.id));
|
|
}} />
|
|
</section>}
|
|
{canPurge && <div>
|
|
<ChannelAction icon="x" quiet danger label={t("room.chat.purgeHistory")} busy={purging} disabled={!available || working}
|
|
onClick={() => {
|
|
if (window.confirm(t("room.chat.confirmPurgeHistory", { name: room.name })))
|
|
void run(() => channel.purgeRoomHistory(room.id));
|
|
}} />
|
|
</div>}
|
|
{room.canManage && backupAvailable && <section className="c3-backup-controls">
|
|
<label className="c3-check"><input type="checkbox" checked={includeFiles} disabled={!available || working}
|
|
onChange={event => setIncludeFiles(event.target.checked)} />{t("room.backup.includeFiles")}</label>
|
|
<p>{t("room.backup.fileScope")}</p>
|
|
{fileLimits && <p>{t("room.backup.fileLimits", { count: String(fileLimits.maxRetainedFiles), size: fileSize(fileLimits.maxRetainedBytes) })}</p>}
|
|
</section>}
|
|
{room.canManage && backupAvailable && <RoomCopyExport channel={channel} roomId={room.id} includeFiles={includeFiles} run={run}
|
|
disabled={!available || busy || removing} busy={backupBusy} />}
|
|
{room.canManage && backupAvailable && <h3>{t("room.backup.title")}</h3>}
|
|
{room.canManage && backupAvailable && inviteOnly && <p>{t("room.backup.inviteOnlyNote")}</p>}
|
|
{room.canManage && <BackupControls onClose={onClose} run={run} available={backupAvailable} disabled={!available || busy || removing || !backupAvailable}
|
|
busy={backupBusy} onExport={() => channel.exportRoomBackup(room.id, includeFiles)} onRestore={async file => {
|
|
try {
|
|
const result = await channel.restoreRoomBackup(file, room.id);
|
|
setDraft({});
|
|
return result;
|
|
} catch (error) {
|
|
if (error instanceof Error && error.message === "room_restored_connection_failed") setDraft({});
|
|
throw error;
|
|
}
|
|
}} />}
|
|
</section>}
|
|
</div>
|
|
</div>
|
|
</ChannelSettingsDialog>;
|
|
}
|