Revert "UnknownDeviceDialog: get devices from SDK"
This commit is contained in:
parent
b575df7da7
commit
7b243bf64d
2 changed files with 15 additions and 49 deletions
|
@ -25,6 +25,7 @@ const onAction = function(payload) {
|
||||||
const UnknownDeviceDialog = sdk.getComponent('dialogs.UnknownDeviceDialog');
|
const UnknownDeviceDialog = sdk.getComponent('dialogs.UnknownDeviceDialog');
|
||||||
isDialogOpen = true;
|
isDialogOpen = true;
|
||||||
Modal.createTrackedDialog('Unknown Device Error', '', UnknownDeviceDialog, {
|
Modal.createTrackedDialog('Unknown Device Error', '', UnknownDeviceDialog, {
|
||||||
|
devices: payload.err.devices,
|
||||||
room: payload.room,
|
room: payload.room,
|
||||||
onFinished: (r) => {
|
onFinished: (r) => {
|
||||||
isDialogOpen = false;
|
isDialogOpen = false;
|
||||||
|
|
|
@ -48,9 +48,8 @@ function UserUnknownDeviceList(props) {
|
||||||
const {userId, userDevices} = props;
|
const {userId, userDevices} = props;
|
||||||
|
|
||||||
const deviceListEntries = Object.keys(userDevices).map((deviceId) =>
|
const deviceListEntries = Object.keys(userDevices).map((deviceId) =>
|
||||||
<DeviceListEntry key={deviceId} userId={userId}
|
<DeviceListEntry key={deviceId} userId={userId}
|
||||||
device={userDevices[deviceId]}
|
device={userDevices[deviceId]} />,
|
||||||
/>,
|
|
||||||
);
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
@ -93,60 +92,26 @@ export default React.createClass({
|
||||||
propTypes: {
|
propTypes: {
|
||||||
room: React.PropTypes.object.isRequired,
|
room: React.PropTypes.object.isRequired,
|
||||||
|
|
||||||
|
// map from userid -> deviceid -> deviceinfo
|
||||||
|
devices: React.PropTypes.object.isRequired,
|
||||||
onFinished: React.PropTypes.func.isRequired,
|
onFinished: React.PropTypes.func.isRequired,
|
||||||
},
|
},
|
||||||
|
|
||||||
componentWillMount: function() {
|
componentDidMount: function() {
|
||||||
this._unmounted = false;
|
// Given we've now shown the user the unknown device, it is no longer
|
||||||
|
// unknown to them. Therefore mark it as 'known'.
|
||||||
const roomMembers = this.props.room.getJoinedMembers().map((m) => {
|
Object.keys(this.props.devices).forEach((userId) => {
|
||||||
return m.userId;
|
Object.keys(this.props.devices[userId]).map((deviceId) => {
|
||||||
});
|
MatrixClientPeg.get().setDeviceKnown(userId, deviceId, true);
|
||||||
|
|
||||||
this.setState({
|
|
||||||
// map from userid -> deviceid -> deviceinfo
|
|
||||||
devices: null,
|
|
||||||
});
|
|
||||||
MatrixClientPeg.get().downloadKeys(roomMembers, false).then((devices) => {
|
|
||||||
if (this._unmounted) return;
|
|
||||||
|
|
||||||
const unknownDevices = {};
|
|
||||||
// This is all devices in this room, so find the unknown ones.
|
|
||||||
Object.keys(devices).forEach((userId) => {
|
|
||||||
Object.keys(devices[userId]).map((deviceId) => {
|
|
||||||
const device = devices[userId][deviceId];
|
|
||||||
|
|
||||||
if (device.isUnverified() && !device.isKnown()) {
|
|
||||||
if (unknownDevices[userId] === undefined) {
|
|
||||||
unknownDevices[userId] = {};
|
|
||||||
}
|
|
||||||
unknownDevices[userId][deviceId] = device;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Given we've now shown the user the unknown device, it is no longer
|
|
||||||
// unknown to them. Therefore mark it as 'known'.
|
|
||||||
if (!device.isKnown()) {
|
|
||||||
MatrixClientPeg.get().setDeviceKnown(userId, deviceId, true);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
this.setState({
|
|
||||||
devices: unknownDevices,
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
},
|
|
||||||
|
|
||||||
componentWillUnmount: function() {
|
// XXX: temporary logging to try to diagnose
|
||||||
this._unmounted = true;
|
// https://github.com/vector-im/riot-web/issues/3148
|
||||||
|
console.log('Opening UnknownDeviceDialog');
|
||||||
},
|
},
|
||||||
|
|
||||||
render: function() {
|
render: function() {
|
||||||
if (this.state.devices === null) {
|
|
||||||
const Spinner = sdk.getComponent("elements.Spinner");
|
|
||||||
return <Spinner />;
|
|
||||||
}
|
|
||||||
|
|
||||||
const client = MatrixClientPeg.get();
|
const client = MatrixClientPeg.get();
|
||||||
const blacklistUnverified = client.getGlobalBlacklistUnverifiedDevices() ||
|
const blacklistUnverified = client.getGlobalBlacklistUnverifiedDevices() ||
|
||||||
this.props.room.getBlacklistUnverifiedDevices();
|
this.props.room.getBlacklistUnverifiedDevices();
|
||||||
|
@ -189,7 +154,7 @@ export default React.createClass({
|
||||||
{ warning }
|
{ warning }
|
||||||
{ _t("Unknown devices") }:
|
{ _t("Unknown devices") }:
|
||||||
|
|
||||||
<UnknownDeviceList devices={this.state.devices} />
|
<UnknownDeviceList devices={this.props.devices} />
|
||||||
</GeminiScrollbar>
|
</GeminiScrollbar>
|
||||||
<div className="mx_Dialog_buttons">
|
<div className="mx_Dialog_buttons">
|
||||||
<button className="mx_Dialog_primary" autoFocus={true}
|
<button className="mx_Dialog_primary" autoFocus={true}
|
||||||
|
|
Loading…
Reference in a new issue