From 436e6b36f1814d13398cd990ed410b6fbaa394b8 Mon Sep 17 00:00:00 2001
From: Luke Barnard
Date: Wed, 22 Feb 2017 16:42:14 +0000
Subject: [PATCH] Move UDE handling to a its own file, adjust wording
---
src/UnknownDeviceErrorHandler.js | 32 +++++++++++++++++++
src/components/structures/MatrixChat.js | 15 ++-------
.../views/dialogs/UnknownDeviceDialog.js | 2 +-
3 files changed, 36 insertions(+), 13 deletions(-)
create mode 100644 src/UnknownDeviceErrorHandler.js
diff --git a/src/UnknownDeviceErrorHandler.js b/src/UnknownDeviceErrorHandler.js
new file mode 100644
index 0000000000..c5a3870f40
--- /dev/null
+++ b/src/UnknownDeviceErrorHandler.js
@@ -0,0 +1,32 @@
+import dis from './dispatcher';
+import sdk from './index';
+import Modal from './Modal';
+
+const onAction = function(payload) {
+ if (payload.action === 'unknown_device_error') {
+ var UnknownDeviceDialog = sdk.getComponent("dialogs.UnknownDeviceDialog");
+ Modal.createDialog(UnknownDeviceDialog, {
+ devices: payload.err.devices,
+ room: payload.room,
+ onFinished: (r) => {
+ // XXX: temporary logging to try to diagnose
+ // https://github.com/vector-im/riot-web/issues/3148
+ console.log('UnknownDeviceDialog closed with '+r);
+ },
+ }, "mx_Dialog_unknownDevice");
+ }
+}
+
+let ref = null;
+
+module.exports = {
+ startListening: function () {
+ ref = dis.register(onAction);
+ },
+ stopListening: function () {
+ if (ref){
+ dis.unregister(ref);
+ ref = null;
+ }
+ },
+};
diff --git a/src/components/structures/MatrixChat.js b/src/components/structures/MatrixChat.js
index a816769891..695e1084fe 100644
--- a/src/components/structures/MatrixChat.js
+++ b/src/components/structures/MatrixChat.js
@@ -42,6 +42,7 @@ var Lifecycle = require('../../Lifecycle');
var PageTypes = require('../../PageTypes');
var createRoom = require("../../createRoom");
+var UDEHandler = require("../../UnknownDeviceErrorHandler");
module.exports = React.createClass({
displayName: 'MatrixChat',
@@ -240,6 +241,7 @@ module.exports = React.createClass({
componentDidMount: function() {
this.dispatcherRef = dis.register(this.onAction);
+ UDEHandler.startListening();
this.focusComposer = false;
window.addEventListener("focus", this.onFocus);
@@ -286,6 +288,7 @@ module.exports = React.createClass({
componentWillUnmount: function() {
Lifecycle.stopMatrixClient();
dis.unregister(this.dispatcherRef);
+ UDEHandler.stopListening();
window.removeEventListener("focus", this.onFocus);
window.removeEventListener('resize', this.handleResize);
},
@@ -519,18 +522,6 @@ module.exports = React.createClass({
case 'set_theme':
this._onSetTheme(payload.value);
break;
- case 'unknown_device_error':
- var UnknownDeviceDialog = sdk.getComponent("dialogs.UnknownDeviceDialog");
- Modal.createDialog(UnknownDeviceDialog, {
- devices: payload.err.devices,
- room: payload.room,
- onFinished: (r) => {
- // XXX: temporary logging to try to diagnose
- // https://github.com/vector-im/riot-web/issues/3148
- console.log('UnknownDeviceDialog closed with '+r);
- },
- }, "mx_Dialog_unknownDevice");
- break;
case 'resend_all_events':
payload.room.getPendingEvents().filter(function(ev) {
return ev.status === Matrix.EventStatus.NOT_SENT;
diff --git a/src/components/views/dialogs/UnknownDeviceDialog.js b/src/components/views/dialogs/UnknownDeviceDialog.js
index 4dc6f9048d..75c27a6f1b 100644
--- a/src/components/views/dialogs/UnknownDeviceDialog.js
+++ b/src/components/views/dialogs/UnknownDeviceDialog.js
@@ -132,7 +132,7 @@ export default React.createClass({
We recommend you go through the verification process
- for each device before continuing, but you can retry
+ for each device before continuing, but you can send
without verifying if you prefer.