add local echo for clicking 'start verification' button
This commit is contained in:
parent
1edda88351
commit
50b64d8c55
1 changed files with 9 additions and 2 deletions
|
@ -37,6 +37,7 @@ const EncryptionPanel = ({verificationRequest, member, onClose, layout}) => {
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setRequest(verificationRequest);
|
setRequest(verificationRequest);
|
||||||
if (verificationRequest) {
|
if (verificationRequest) {
|
||||||
|
setRequesting(false);
|
||||||
setPhase(verificationRequest.phase);
|
setPhase(verificationRequest.phase);
|
||||||
}
|
}
|
||||||
}, [verificationRequest]);
|
}, [verificationRequest]);
|
||||||
|
@ -67,7 +68,11 @@ const EncryptionPanel = ({verificationRequest, member, onClose, layout}) => {
|
||||||
}, [onClose, request]);
|
}, [onClose, request]);
|
||||||
useEventEmitter(request, "change", changeHandler);
|
useEventEmitter(request, "change", changeHandler);
|
||||||
|
|
||||||
|
// state to show a spinner immediately after clicking "start verification",
|
||||||
|
// before we have a request
|
||||||
|
const [isRequesting, setRequesting] = useState(false);
|
||||||
const onStartVerification = useCallback(async () => {
|
const onStartVerification = useCallback(async () => {
|
||||||
|
setRequesting(true);
|
||||||
const cli = MatrixClientPeg.get();
|
const cli = MatrixClientPeg.get();
|
||||||
const roomId = await ensureDMExists(cli, member.userId);
|
const roomId = await ensureDMExists(cli, member.userId);
|
||||||
const verificationRequest = await cli.requestVerificationDM(member.userId, roomId);
|
const verificationRequest = await cli.requestVerificationDM(member.userId, roomId);
|
||||||
|
@ -75,9 +80,11 @@ const EncryptionPanel = ({verificationRequest, member, onClose, layout}) => {
|
||||||
setPhase(verificationRequest.phase);
|
setPhase(verificationRequest.phase);
|
||||||
}, [member.userId]);
|
}, [member.userId]);
|
||||||
|
|
||||||
const requested = request && (phase === PHASE_REQUESTED || phase === PHASE_UNSENT || phase === undefined);
|
const requested =
|
||||||
const initiatedByMe = request && request.initiatedByMe;
|
(!request && isRequesting) ||
|
||||||
|
(request && (phase === PHASE_REQUESTED || phase === PHASE_UNSENT || phase === undefined));
|
||||||
if (!request || requested) {
|
if (!request || requested) {
|
||||||
|
const initiatedByMe = (!request && isRequesting) || (request && request.initiatedByMe);
|
||||||
return <EncryptionInfo
|
return <EncryptionInfo
|
||||||
onStartVerification={onStartVerification}
|
onStartVerification={onStartVerification}
|
||||||
member={member}
|
member={member}
|
||||||
|
|
Loading…
Reference in a new issue