mirror of
https://github.com/cinnyapp/cinny.git
synced 2025-02-12 00:33:36 +01:00
allow displayname change based on capabilities check
This commit is contained in:
parent
77111f8135
commit
a1b2e36fcc
1 changed files with 10 additions and 2 deletions
|
@ -237,6 +237,9 @@ function ProfileAvatar({ profile, userId }: ProfileProps) {
|
|||
|
||||
function ProfileDisplayName({ profile, userId }: ProfileProps) {
|
||||
const mx = useMatrixClient();
|
||||
const capabilities = useCapabilities();
|
||||
const disableSetDisplayname = capabilities['m.set_displayname']?.enabled === false;
|
||||
|
||||
const defaultDisplayName = profile.displayName ?? getMxIdLocalPart(userId) ?? userId;
|
||||
const [displayName, setDisplayName] = useState(defaultDisplayName);
|
||||
|
||||
|
@ -276,7 +279,12 @@ function ProfileDisplayName({ profile, userId }: ProfileProps) {
|
|||
}
|
||||
>
|
||||
<Box direction="Column" grow="Yes" gap="100">
|
||||
<Box as="form" onSubmit={handleSubmit} gap="200" aria-disabled={changingDisplayName}>
|
||||
<Box
|
||||
as="form"
|
||||
onSubmit={handleSubmit}
|
||||
gap="200"
|
||||
aria-disabled={changingDisplayName || disableSetDisplayname}
|
||||
>
|
||||
<Box grow="Yes" direction="Column">
|
||||
<Input
|
||||
required
|
||||
|
@ -286,7 +294,7 @@ function ProfileDisplayName({ profile, userId }: ProfileProps) {
|
|||
variant="Secondary"
|
||||
radii="300"
|
||||
style={{ paddingRight: config.space.S200 }}
|
||||
readOnly={changingDisplayName}
|
||||
readOnly={changingDisplayName || disableSetDisplayname}
|
||||
after={
|
||||
hasChanges &&
|
||||
!changingDisplayName && (
|
||||
|
|
Loading…
Reference in a new issue