Merge pull request #4138 from matrix-org/bwindels/moreverifuifeedback
add local echo for clicking 'start verification' button
This commit is contained in:
commit
f45dd311f9
1 changed files with 9 additions and 3 deletions
|
@ -32,11 +32,14 @@ const MISMATCHES = ["m.key_mismatch", "m.user_error", "m.mismatched_sas"];
|
||||||
|
|
||||||
const EncryptionPanel = ({verificationRequest, member, onClose, layout}) => {
|
const EncryptionPanel = ({verificationRequest, member, onClose, layout}) => {
|
||||||
const [request, setRequest] = useState(verificationRequest);
|
const [request, setRequest] = useState(verificationRequest);
|
||||||
|
// state to show a spinner immediately after clicking "start verification",
|
||||||
|
// before we have a request
|
||||||
|
const [isRequesting, setRequesting] = useState(false);
|
||||||
const [phase, setPhase] = useState(request && request.phase);
|
const [phase, setPhase] = useState(request && request.phase);
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setRequest(verificationRequest);
|
setRequest(verificationRequest);
|
||||||
if (verificationRequest) {
|
if (verificationRequest) {
|
||||||
|
setRequesting(false);
|
||||||
setPhase(verificationRequest.phase);
|
setPhase(verificationRequest.phase);
|
||||||
}
|
}
|
||||||
}, [verificationRequest]);
|
}, [verificationRequest]);
|
||||||
|
@ -68,6 +71,7 @@ const EncryptionPanel = ({verificationRequest, member, onClose, layout}) => {
|
||||||
useEventEmitter(request, "change", changeHandler);
|
useEventEmitter(request, "change", changeHandler);
|
||||||
|
|
||||||
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 +79,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