refactor(ui): reuse room settings and clarify connection controls
This commit is contained in:
1 parent
4d19e02e85
commit
aaadcee23d
3 files changed
+8
-8
No files matched your search
@@ -20,7 +20,7 @@ in place. The tabs show the tasks available to you:
|
||||
- **Invitation:** Copy the private-room invitation or open its QR code. Under
|
||||
**Users with access**, **Remove room access** ends that user's access and
|
||||
activities in this room; they need a new grant to return.
|
||||
- **My forwarding:** Choose how many people this device helps forward to in this room.
|
||||
- **Connection settings:** Choose how many people this device helps forward to in this room.
|
||||
- **Records and backups:** Export chat, or export a room backup when you manage
|
||||
its host. To restore, select **Restore backup**, choose the ZIP and read the
|
||||
replacement notice before **Confirm**. Restoration replaces this room's
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
|
||||
- **房间:** 修改名称、图片或访问方式,再点**保存**。**对未获准的用户隐藏房间**会让尚未获准的人看不到该私密房间。
|
||||
- **邀请:** 复制私密房间邀请或打开二维码。在**已获准的用户**中,**移除房间资格**会结束该用户在此房间的访问和活动;再次进入需要重新获准。
|
||||
- **我的转发:** 选择这台设备在本房间最多帮多少人转发。
|
||||
- **连接设置:** 选择这台设备在本房间最多帮多少人转发。
|
||||
- **记录与备份:** 导出聊天;管理房间托管端时还可导出房间备份。恢复时点**从备份恢复**,选择 ZIP,阅读替换提示后再点**确认**。恢复会替换此房间的设置和消息。
|
||||
|
||||
更换邀请不会撤销已获准用户的资格。需要换新链接时,展开**重置房间邀请**,再点**生成新邀请**。
|
||||
|
||||
@@ -46,7 +46,7 @@ function RelayLimit({ value, min, label, note, disabled, onChange }: {
|
||||
</NumberControl>;
|
||||
}
|
||||
|
||||
function PersonalRelay({ channel, room, disabled, run }: { channel: ChannelController; room: ChannelRoom; disabled: boolean; run: SettingsAction }) {
|
||||
export function PersonalRelay({ channel, room, disabled, run }: { channel: ChannelController; room: ChannelRoom; disabled: boolean; run: SettingsAction }) {
|
||||
const { lang } = useCopy(), zh = lang === "zh";
|
||||
const host = room.delivery?.hostSessionId === channel.sessionId;
|
||||
const following = room.relayOverride === null;
|
||||
@@ -64,13 +64,13 @@ function PersonalRelay({ channel, room, disabled, run }: { channel: ChannelContr
|
||||
</section>;
|
||||
}
|
||||
|
||||
type RoomDraft = Pick<RoomSettings, "name" | "icon" | "access" | "hidden"> & { password: string; removePassword: boolean; relayCapacity: number };
|
||||
function roomDraft(room?: ChannelRoom): RoomDraft {
|
||||
export type RoomDraft = Pick<RoomSettings, "name" | "icon" | "access" | "hidden"> & { password: string; removePassword: boolean; relayCapacity: number };
|
||||
export function roomDraft(room?: ChannelRoom): RoomDraft {
|
||||
return { name: room?.name ?? "", icon: room?.icon ?? "couch", access: room?.access ?? "public", hidden: room?.hidden ?? false,
|
||||
password: "", removePassword: false, relayCapacity: room?.relayCapacity ?? DEFAULT_RELAY_CAPACITY };
|
||||
}
|
||||
|
||||
function RoomForm({ room, value, onChange, appHosted, disabled, busy, onSave, onCancel }: {
|
||||
export function RoomForm({ room, value, onChange, appHosted, disabled, busy, onSave, onCancel }: {
|
||||
room?: ChannelRoom; value: RoomDraft; onChange(value: Partial<RoomDraft>): void; appHosted: boolean; disabled: boolean; busy: boolean;
|
||||
onSave: (settings: RoomSettings) => Promise<unknown>; onCancel(): void;
|
||||
}) {
|
||||
@@ -206,7 +206,7 @@ function RoomSettings({ channel, room, onClose }: {
|
||||
const tasks = [
|
||||
...(room.canManage ? [{ value: "room", label: zh ? "房间" : "Room", icon: "couch", hint: "hint-advanced" } as const] : []),
|
||||
{ value: "invitation", label: zh ? "邀请" : "Invitation", icon: "link", hint: "hint-copy-invite" } as const,
|
||||
...(room.authorized ? [{ value: "relay", label: zh ? "我的转发" : "My forwarding", icon: "branch", hint: "hint-relay-volunteer" } as const] : []),
|
||||
...(room.authorized ? [{ value: "relay", label: zh ? "连接设置" : "Connection settings", icon: "branch", hint: "hint-relay-volunteer" } as const] : []),
|
||||
...(room.authorized || room.canManage ? [{ value: "data", label: zh ? "记录与备份" : "Records and backups", icon: "save", hint: "hint-chat-export" } as const] : []),
|
||||
];
|
||||
const selected = tasks.some(value => value.value === task) ? task : "invitation";
|
||||
@@ -258,7 +258,7 @@ function RoomSettings({ channel, room, onClose }: {
|
||||
</section>}
|
||||
</section>
|
||||
{room.authorized && <section id={`${id}-relay`} role="tabpanel" aria-labelledby={`${id}-relay-tab`} hidden={selected !== "relay"}>
|
||||
<h3>{zh ? "我的转发" : "My forwarding"}</h3>
|
||||
<h3>{zh ? "连接设置" : "Connection settings"}</h3>
|
||||
<PersonalRelay 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"}>
|
||||
|
||||
Reference in new issue
Block a user