Merge pull request #4284 from matrix-org/bwindels/showverifreqinsteadofmember
Show ongoing verification request straight away when navigating to member
This commit is contained in:
commit
528c820a2b
2 changed files with 27 additions and 10 deletions
|
@ -15,6 +15,7 @@ limitations under the License.
|
|||
*/
|
||||
|
||||
import dis from '../dispatcher';
|
||||
import {pendingVerificationRequestForUser} from '../verification';
|
||||
import {Store} from 'flux/utils';
|
||||
import SettingsStore, {SettingLevel} from "../settings/SettingsStore";
|
||||
import {RIGHT_PANEL_PHASES, RIGHT_PANEL_PHASES_NO_ARGS} from "./RightPanelStorePhases";
|
||||
|
@ -135,7 +136,20 @@ export default class RightPanelStore extends Store {
|
|||
break;
|
||||
|
||||
case 'set_right_panel_phase': {
|
||||
const targetPhase = payload.phase;
|
||||
let targetPhase = payload.phase;
|
||||
let refireParams = payload.refireParams;
|
||||
// redirect to EncryptionPanel if there is an ongoing verification request
|
||||
if (targetPhase === RIGHT_PANEL_PHASES.RoomMemberInfo) {
|
||||
const {member} = payload.refireParams;
|
||||
const pendingRequest = pendingVerificationRequestForUser(member);
|
||||
if (pendingRequest) {
|
||||
targetPhase = RIGHT_PANEL_PHASES.EncryptionPanel;
|
||||
refireParams = {
|
||||
verificationRequest: pendingRequest,
|
||||
member,
|
||||
};
|
||||
}
|
||||
}
|
||||
if (!RIGHT_PANEL_PHASES[targetPhase]) {
|
||||
console.warn(`Tried to switch right panel to unknown phase: ${targetPhase}`);
|
||||
return;
|
||||
|
@ -153,7 +167,7 @@ export default class RightPanelStore extends Store {
|
|||
});
|
||||
}
|
||||
} else {
|
||||
if (targetPhase === this._state.lastRoomPhase && !payload.refireParams) {
|
||||
if (targetPhase === this._state.lastRoomPhase && !refireParams) {
|
||||
this._setState({
|
||||
showRoomPanel: !this._state.showRoomPanel,
|
||||
});
|
||||
|
@ -161,7 +175,7 @@ export default class RightPanelStore extends Store {
|
|||
this._setState({
|
||||
lastRoomPhase: targetPhase,
|
||||
showRoomPanel: true,
|
||||
lastRoomPhaseParams: payload.refireParams || {},
|
||||
lastRoomPhaseParams: refireParams || {},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -170,7 +184,7 @@ export default class RightPanelStore extends Store {
|
|||
dis.dispatch({
|
||||
action: 'after_right_panel_phase_change',
|
||||
phase: targetPhase,
|
||||
...(payload.refireParams || {}),
|
||||
...(refireParams || {}),
|
||||
});
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -111,12 +111,7 @@ export async function verifyUser(user) {
|
|||
if (!await enable4SIfNeeded()) {
|
||||
return;
|
||||
}
|
||||
const cli = MatrixClientPeg.get();
|
||||
const dmRoom = findDMForUser(cli, user.userId);
|
||||
let existingRequest;
|
||||
if (dmRoom) {
|
||||
existingRequest = cli.findVerificationRequestDMInProgress(dmRoom.roomId);
|
||||
}
|
||||
const existingRequest = pendingVerificationRequestForUser(user);
|
||||
dis.dispatch({
|
||||
action: "set_right_panel_phase",
|
||||
phase: RIGHT_PANEL_PHASES.EncryptionPanel,
|
||||
|
@ -126,3 +121,11 @@ export async function verifyUser(user) {
|
|||
},
|
||||
});
|
||||
}
|
||||
|
||||
export function pendingVerificationRequestForUser(user) {
|
||||
const cli = MatrixClientPeg.get();
|
||||
const dmRoom = findDMForUser(cli, user.userId);
|
||||
if (dmRoom) {
|
||||
return cli.findVerificationRequestDMInProgress(dmRoom.roomId);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue