mirror of
https://github.com/element-hq/element-web
synced 2024-11-27 11:47:23 +03:00
Debounce User Info start dm "Message" button (#7357)
This commit is contained in:
parent
d00809b8b9
commit
361e9e4360
2 changed files with 25 additions and 9 deletions
|
@ -120,7 +120,7 @@ export const getE2EStatus = (cli: MatrixClient, userId: string, devices: IDevice
|
||||||
return anyDeviceUnverified ? E2EStatus.Warning : E2EStatus.Verified;
|
return anyDeviceUnverified ? E2EStatus.Warning : E2EStatus.Verified;
|
||||||
};
|
};
|
||||||
|
|
||||||
async function openDMForUser(matrixClient: MatrixClient, userId: string) {
|
async function openDMForUser(matrixClient: MatrixClient, userId: string): Promise<void> {
|
||||||
const lastActiveRoom = findDMForUser(matrixClient, userId);
|
const lastActiveRoom = findDMForUser(matrixClient, userId);
|
||||||
|
|
||||||
if (lastActiveRoom) {
|
if (lastActiveRoom) {
|
||||||
|
@ -149,7 +149,7 @@ async function openDMForUser(matrixClient: MatrixClient, userId: string) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return createRoom(createRoomOptions);
|
await createRoom(createRoomOptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
type SetUpdating = (updating: boolean) => void;
|
type SetUpdating = (updating: boolean) => void;
|
||||||
|
@ -318,6 +318,26 @@ function DevicesSection({ devices, userId, loading }: {devices: IDevice[], userI
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const MessageButton = ({ userId }: { userId: string }) => {
|
||||||
|
const cli = useContext(MatrixClientContext);
|
||||||
|
const [busy, setBusy] = useState(false);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<AccessibleButton
|
||||||
|
onClick={async () => {
|
||||||
|
if (busy) return;
|
||||||
|
setBusy(true);
|
||||||
|
await openDMForUser(cli, userId);
|
||||||
|
setBusy(false);
|
||||||
|
}}
|
||||||
|
className="mx_UserInfo_field"
|
||||||
|
disabled={busy}
|
||||||
|
>
|
||||||
|
{ _t("Message") }
|
||||||
|
</AccessibleButton>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
const UserOptionsSection: React.FC<{
|
const UserOptionsSection: React.FC<{
|
||||||
member: RoomMember;
|
member: RoomMember;
|
||||||
isIgnored: boolean;
|
isIgnored: boolean;
|
||||||
|
@ -432,13 +452,9 @@ const UserOptionsSection: React.FC<{
|
||||||
</AccessibleButton>
|
</AccessibleButton>
|
||||||
);
|
);
|
||||||
|
|
||||||
let directMessageButton;
|
let directMessageButton: JSX.Element;
|
||||||
if (!isMe) {
|
if (!isMe) {
|
||||||
directMessageButton = (
|
directMessageButton = <MessageButton userId={member.userId} />;
|
||||||
<AccessibleButton onClick={() => { openDMForUser(cli, member.userId); }} className="mx_UserInfo_field">
|
|
||||||
{ _t("Message") }
|
|
||||||
</AccessibleButton>
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
|
@ -1927,10 +1927,10 @@
|
||||||
"%(count)s sessions|other": "%(count)s sessions",
|
"%(count)s sessions|other": "%(count)s sessions",
|
||||||
"%(count)s sessions|one": "%(count)s session",
|
"%(count)s sessions|one": "%(count)s session",
|
||||||
"Hide sessions": "Hide sessions",
|
"Hide sessions": "Hide sessions",
|
||||||
|
"Message": "Message",
|
||||||
"Jump to read receipt": "Jump to read receipt",
|
"Jump to read receipt": "Jump to read receipt",
|
||||||
"Mention": "Mention",
|
"Mention": "Mention",
|
||||||
"Share Link to User": "Share Link to User",
|
"Share Link to User": "Share Link to User",
|
||||||
"Message": "Message",
|
|
||||||
"Demote yourself?": "Demote yourself?",
|
"Demote yourself?": "Demote yourself?",
|
||||||
"You will not be able to undo this change as you are demoting yourself, if you are the last privileged user in the space it will be impossible to regain privileges.": "You will not be able to undo this change as you are demoting yourself, if you are the last privileged user in the space it will be impossible to regain privileges.",
|
"You will not be able to undo this change as you are demoting yourself, if you are the last privileged user in the space it will be impossible to regain privileges.": "You will not be able to undo this change as you are demoting yourself, if you are the last privileged user in the space it will be impossible to regain privileges.",
|
||||||
"You will not be able to undo this change as you are demoting yourself, if you are the last privileged user in the room it will be impossible to regain privileges.": "You will not be able to undo this change as you are demoting yourself, if you are the last privileged user in the room it will be impossible to regain privileges.",
|
"You will not be able to undo this change as you are demoting yourself, if you are the last privileged user in the room it will be impossible to regain privileges.": "You will not be able to undo this change as you are demoting yourself, if you are the last privileged user in the room it will be impossible to regain privileges.",
|
||||||
|
|
Loading…
Reference in a new issue