mirror of
https://github.com/cinnyapp/cinny.git
synced 2025-02-13 16:13:24 +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) {
|
function ProfileDisplayName({ profile, userId }: ProfileProps) {
|
||||||
const mx = useMatrixClient();
|
const mx = useMatrixClient();
|
||||||
|
const capabilities = useCapabilities();
|
||||||
|
const disableSetDisplayname = capabilities['m.set_displayname']?.enabled === false;
|
||||||
|
|
||||||
const defaultDisplayName = profile.displayName ?? getMxIdLocalPart(userId) ?? userId;
|
const defaultDisplayName = profile.displayName ?? getMxIdLocalPart(userId) ?? userId;
|
||||||
const [displayName, setDisplayName] = useState(defaultDisplayName);
|
const [displayName, setDisplayName] = useState(defaultDisplayName);
|
||||||
|
|
||||||
|
@ -276,7 +279,12 @@ function ProfileDisplayName({ profile, userId }: ProfileProps) {
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
<Box direction="Column" grow="Yes" gap="100">
|
<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">
|
<Box grow="Yes" direction="Column">
|
||||||
<Input
|
<Input
|
||||||
required
|
required
|
||||||
|
@ -286,7 +294,7 @@ function ProfileDisplayName({ profile, userId }: ProfileProps) {
|
||||||
variant="Secondary"
|
variant="Secondary"
|
||||||
radii="300"
|
radii="300"
|
||||||
style={{ paddingRight: config.space.S200 }}
|
style={{ paddingRight: config.space.S200 }}
|
||||||
readOnly={changingDisplayName}
|
readOnly={changingDisplayName || disableSetDisplayname}
|
||||||
after={
|
after={
|
||||||
hasChanges &&
|
hasChanges &&
|
||||||
!changingDisplayName && (
|
!changingDisplayName && (
|
||||||
|
|
Loading…
Reference in a new issue