Room Settings → General now reads e.g. "Encrypted · Invite only · History visible to members since they joined" under the name — derived from m.room.encryption, m.room.join_rules and m.room.history_visibility with the same words the preview-card chips and the history setting use. One Text line, no card, no icons, no controls; spec defaults (invite-only, shared history) when a state event is absent. Unit-tested. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PPmy3tPq869XDW4njjVaKA
50 lines
1.6 KiB
TypeScript
50 lines
1.6 KiB
TypeScript
import { HistoryVisibility, JoinRule } from 'matrix-js-sdk';
|
|
|
|
/**
|
|
* [Gitea #133] One sentence for Room Settings → General, under the name:
|
|
* "Encrypted · Invite only · History visible to members since they joined".
|
|
* Wording mirrors the room preview card chips and the history-visibility
|
|
* setting so the same words mean the same thing everywhere.
|
|
*/
|
|
export function describeRoomVisibility(input: {
|
|
encrypted: boolean;
|
|
joinRule?: string;
|
|
historyVisibility?: string;
|
|
}): string {
|
|
const parts: string[] = [input.encrypted ? 'Encrypted' : 'Not encrypted'];
|
|
switch (input.joinRule) {
|
|
case JoinRule.Public:
|
|
parts.push('Anyone can join');
|
|
break;
|
|
case JoinRule.Knock:
|
|
case 'knock_restricted':
|
|
parts.push('Ask to join');
|
|
break;
|
|
case JoinRule.Restricted:
|
|
parts.push('Restricted');
|
|
break;
|
|
case JoinRule.Private:
|
|
parts.push('Private');
|
|
break;
|
|
case JoinRule.Invite:
|
|
default:
|
|
parts.push('Invite only');
|
|
}
|
|
switch (input.historyVisibility) {
|
|
case HistoryVisibility.WorldReadable:
|
|
parts.push('History visible to anyone, even guests');
|
|
break;
|
|
case HistoryVisibility.Invited:
|
|
parts.push('History visible to members since they were invited');
|
|
break;
|
|
case HistoryVisibility.Joined:
|
|
parts.push('History visible to members since they joined');
|
|
break;
|
|
case HistoryVisibility.Shared:
|
|
default:
|
|
// "shared" is also the spec default when the state event is absent.
|
|
parts.push('History visible to members, including before they joined');
|
|
}
|
|
return parts.join(' · ');
|
|
}
|