From c13ff254b1c530601e6996039b14bfe429aadb9f Mon Sep 17 00:00:00 2001
From: Luke Barnard
Date: Wed, 22 Feb 2017 10:21:43 +0000
Subject: [PATCH] Add "Retry" button to UDE
---
src/components/structures/MatrixChat.js | 15 +++++++++++++++
src/components/structures/RoomView.js | 12 ++++++------
.../views/dialogs/UnknownDeviceDialog.js | 15 +++++++++++++--
3 files changed, 34 insertions(+), 8 deletions(-)
diff --git a/src/components/structures/MatrixChat.js b/src/components/structures/MatrixChat.js
index 6b191305f2..a816769891 100644
--- a/src/components/structures/MatrixChat.js
+++ b/src/components/structures/MatrixChat.js
@@ -26,6 +26,7 @@ var ContextualMenu = require("./ContextualMenu");
var RoomListSorter = require("../../RoomListSorter");
var UserActivity = require("../../UserActivity");
var Presence = require("../../Presence");
+var Resend = require("../../Resend");
var dis = require("../../dispatcher");
var Login = require("./login/Login");
@@ -530,6 +531,20 @@ module.exports = React.createClass({
},
}, "mx_Dialog_unknownDevice");
break;
+ case 'resend_all_events':
+ payload.room.getPendingEvents().filter(function(ev) {
+ return ev.status === Matrix.EventStatus.NOT_SENT;
+ }).forEach(function(event) {
+ Resend.resend(event);
+ });
+ break;
+ case 'cancel_all_events':
+ payload.room.getPendingEvents().filter(function(ev) {
+ return ev.status === Matrix.EventStatus.NOT_SENT;
+ }).forEach(function(event) {
+ Resend.removeFromQueue(event);
+ });
+ break;
case 'on_logged_in':
this._onLoggedIn();
break;
diff --git a/src/components/structures/RoomView.js b/src/components/structures/RoomView.js
index acdea38c69..f3d62699d9 100644
--- a/src/components/structures/RoomView.js
+++ b/src/components/structures/RoomView.js
@@ -716,16 +716,16 @@ module.exports = React.createClass({
},
onResendAllClick: function() {
- var eventsToResend = this._getUnsentMessages(this.state.room);
- eventsToResend.forEach(function(event) {
- Resend.resend(event);
+ dis.dispatch({
+ action: 'resend_all_events',
+ room: this.state.room,
});
},
onCancelAllClick: function() {
- var eventsToResend = this._getUnsentMessages(this.state.room);
- eventsToResend.forEach(function(event) {
- Resend.removeFromQueue(event);
+ dis.dispatch({
+ action: 'cancel_all_events',
+ room: this.state.room,
});
},
diff --git a/src/components/views/dialogs/UnknownDeviceDialog.js b/src/components/views/dialogs/UnknownDeviceDialog.js
index 9b043814bc..880ea0e2b4 100644
--- a/src/components/views/dialogs/UnknownDeviceDialog.js
+++ b/src/components/views/dialogs/UnknownDeviceDialog.js
@@ -16,6 +16,7 @@ limitations under the License.
import React from 'react';
import sdk from '../../../index';
+import dis from '../../../dispatcher';
import MatrixClientPeg from '../../../MatrixClientPeg';
import GeminiScrollbar from 'react-gemini-scrollbar';
@@ -131,8 +132,8 @@ export default React.createClass({
We recommend you go through the verification process
- for each device before continuing, but you can resend
- the message without verifying if you prefer.
+ for each device before continuing, but you can retry
+ without verifying if you prefer.
);
@@ -160,6 +161,16 @@ export default React.createClass({
+ {
+ this.props.onFinished();
+ dis.dispatch({
+ action: 'resend_all_events',
+ room: this.props.room,
+ });
+ }}>
+ Retry
+
{
// XXX: temporary logging to try to diagnose