Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit be5e672

Browse files
authored
Merge pull request #1594 from matrix-org/revert-1584-dbkr/udd_devices_from_sdk
Revert "UnknownDeviceDialog: get devices from SDK"
2 parents b575df7 + 7b243bf commit be5e672

File tree

2 files changed

+15
-49
lines changed

2 files changed

+15
-49
lines changed

src/UnknownDeviceErrorHandler.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ const onAction = function(payload) {
2525
const UnknownDeviceDialog = sdk.getComponent('dialogs.UnknownDeviceDialog');
2626
isDialogOpen = true;
2727
Modal.createTrackedDialog('Unknown Device Error', '', UnknownDeviceDialog, {
28+
devices: payload.err.devices,
2829
room: payload.room,
2930
onFinished: (r) => {
3031
isDialogOpen = false;

src/components/views/dialogs/UnknownDeviceDialog.js

Lines changed: 14 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,8 @@ function UserUnknownDeviceList(props) {
4848
const {userId, userDevices} = props;
4949

5050
const deviceListEntries = Object.keys(userDevices).map((deviceId) =>
51-
<DeviceListEntry key={deviceId} userId={userId}
52-
device={userDevices[deviceId]}
53-
/>,
51+
<DeviceListEntry key={deviceId} userId={userId}
52+
device={userDevices[deviceId]} />,
5453
);
5554

5655
return (
@@ -93,60 +92,26 @@ export default React.createClass({
9392
propTypes: {
9493
room: React.PropTypes.object.isRequired,
9594

95+
// map from userid -> deviceid -> deviceinfo
96+
devices: React.PropTypes.object.isRequired,
9697
onFinished: React.PropTypes.func.isRequired,
9798
},
9899

99-
componentWillMount: function() {
100-
this._unmounted = false;
101-
102-
const roomMembers = this.props.room.getJoinedMembers().map((m) => {
103-
return m.userId;
104-
});
105-
106-
this.setState({
107-
// map from userid -> deviceid -> deviceinfo
108-
devices: null,
109-
});
110-
MatrixClientPeg.get().downloadKeys(roomMembers, false).then((devices) => {
111-
if (this._unmounted) return;
112-
113-
const unknownDevices = {};
114-
// This is all devices in this room, so find the unknown ones.
115-
Object.keys(devices).forEach((userId) => {
116-
Object.keys(devices[userId]).map((deviceId) => {
117-
const device = devices[userId][deviceId];
118-
119-
if (device.isUnverified() && !device.isKnown()) {
120-
if (unknownDevices[userId] === undefined) {
121-
unknownDevices[userId] = {};
122-
}
123-
unknownDevices[userId][deviceId] = device;
124-
}
125-
126-
// Given we've now shown the user the unknown device, it is no longer
127-
// unknown to them. Therefore mark it as 'known'.
128-
if (!device.isKnown()) {
129-
MatrixClientPeg.get().setDeviceKnown(userId, deviceId, true);
130-
}
131-
});
132-
});
133-
134-
this.setState({
135-
devices: unknownDevices,
100+
componentDidMount: function() {
101+
// Given we've now shown the user the unknown device, it is no longer
102+
// unknown to them. Therefore mark it as 'known'.
103+
Object.keys(this.props.devices).forEach((userId) => {
104+
Object.keys(this.props.devices[userId]).map((deviceId) => {
105+
MatrixClientPeg.get().setDeviceKnown(userId, deviceId, true);
136106
});
137107
});
138-
},
139108

140-
componentWillUnmount: function() {
141-
this._unmounted = true;
109+
// XXX: temporary logging to try to diagnose
110+
// https://github.com/vector-im/riot-web/issues/3148
111+
console.log('Opening UnknownDeviceDialog');
142112
},
143113

144114
render: function() {
145-
if (this.state.devices === null) {
146-
const Spinner = sdk.getComponent("elements.Spinner");
147-
return <Spinner />;
148-
}
149-
150115
const client = MatrixClientPeg.get();
151116
const blacklistUnverified = client.getGlobalBlacklistUnverifiedDevices() ||
152117
this.props.room.getBlacklistUnverifiedDevices();
@@ -189,7 +154,7 @@ export default React.createClass({
189154
{ warning }
190155
{ _t("Unknown devices") }:
191156

192-
<UnknownDeviceList devices={this.state.devices} />
157+
<UnknownDeviceList devices={this.props.devices} />
193158
</GeminiScrollbar>
194159
<div className="mx_Dialog_buttons">
195160
<button className="mx_Dialog_primary" autoFocus={true}

0 commit comments

Comments
 (0)