mirror of https://github.com/vector-im/riot-web
Debounce User Info start dm "Message" button (#7357)
parent
d00809b8b9
commit
361e9e4360
|
@ -120,7 +120,7 @@ export const getE2EStatus = (cli: MatrixClient, userId: string, devices: IDevice
|
|||
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);
|
||||
|
||||
if (lastActiveRoom) {
|
||||
|
@ -149,7 +149,7 @@ async function openDMForUser(matrixClient: MatrixClient, userId: string) {
|
|||
}
|
||||
}
|
||||
|
||||
return createRoom(createRoomOptions);
|
||||
await createRoom(createRoomOptions);
|
||||
}
|
||||
|
||||
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<{
|
||||
member: RoomMember;
|
||||
isIgnored: boolean;
|
||||
|
@ -432,13 +452,9 @@ const UserOptionsSection: React.FC<{
|
|||
</AccessibleButton>
|
||||
);
|
||||
|
||||
let directMessageButton;
|
||||
let directMessageButton: JSX.Element;
|
||||
if (!isMe) {
|
||||
directMessageButton = (
|
||||
<AccessibleButton onClick={() => { openDMForUser(cli, member.userId); }} className="mx_UserInfo_field">
|
||||
{ _t("Message") }
|
||||
</AccessibleButton>
|
||||
);
|
||||
directMessageButton = <MessageButton userId={member.userId} />;
|
||||
}
|
||||
|
||||
return (
|
||||
|
|
|
@ -1927,10 +1927,10 @@
|
|||
"%(count)s sessions|other": "%(count)s sessions",
|
||||
"%(count)s sessions|one": "%(count)s session",
|
||||
"Hide sessions": "Hide sessions",
|
||||
"Message": "Message",
|
||||
"Jump to read receipt": "Jump to read receipt",
|
||||
"Mention": "Mention",
|
||||
"Share Link to User": "Share Link to User",
|
||||
"Message": "Message",
|
||||
"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 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 New Issue