From 18490377f80ef68e721dde7bd62aa3eebb0aa823 Mon Sep 17 00:00:00 2001 From: Will Hunt Date: Sat, 10 Jun 2017 14:26:27 +0100 Subject: [PATCH 1/3] Show reason for a call hanging up unexpectedly. --- src/TextForEvent.js | 23 ++++++++++++++++------- src/i18n/strings/en_EN.json | 2 ++ src/i18n/strings/en_US.json | 2 ++ 3 files changed, 20 insertions(+), 7 deletions(-) diff --git a/src/TextForEvent.js b/src/TextForEvent.js index fa78f9d61b..61e821d7cb 100644 --- a/src/TextForEvent.js +++ b/src/TextForEvent.js @@ -13,9 +13,8 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ - -var MatrixClientPeg = require("./MatrixClientPeg"); -var CallHandler = require("./CallHandler"); +import MatrixClientPeg from "./MatrixClientPeg"; +import CallHandler from "./CallHandler"; import { _t } from './languageHandler'; import * as Roles from './Roles'; @@ -117,7 +116,7 @@ function textForTopicEvent(ev) { function textForRoomNameEvent(ev) { var senderDisplayName = ev.sender && ev.sender.name ? ev.sender.name : ev.getSender(); - + if (!ev.getContent().name || ev.getContent().name.trim().length === 0) { return _t('%(senderDisplayName)s removed the room name.', {senderDisplayName: senderDisplayName}); } @@ -142,9 +141,19 @@ function textForCallAnswerEvent(event) { } function textForCallHangupEvent(event) { - var senderName = event.sender ? event.sender.name : _t('Someone'); - var supported = MatrixClientPeg.get().supportsVoip() ? "" : _t('(not supported by this browser)'); - return _t('%(senderName)s ended the call.', {senderName: senderName}) + ' ' + supported; + const senderName = event.sender ? event.sender.name : _t('Someone'); + const eventContent = event.getContent(); + let reason = ""; + if(!MatrixClientPeg.get().supportsVoip()) { + reason = '(not supported by this browser)'; + } else if(eventContent.reason) { + if (eventContent.reason === "ice_failed") { + reason = "(call failed to connect)"; + } else { + reason = `(${eventContent.reason})`; + } + } + return _t('%(senderName)s ended the call.', {senderName}) + ' ' + _t(reason); } function textForCallInviteEvent(event) { diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json index c7c6cd6ef3..ed931c917f 100644 --- a/src/i18n/strings/en_EN.json +++ b/src/i18n/strings/en_EN.json @@ -637,6 +637,8 @@ "VoIP conference finished.": "VoIP conference finished.", "VoIP conference started.": "VoIP conference started.", "VoIP is unsupported": "VoIP is unsupported", + "(call failed to connect)": "(call failed to connect)", + "(unknown failure)": "(unknown failure)", "(warning: cannot be disabled again!)": "(warning: cannot be disabled again!)", "Warning!": "Warning!", "WARNING: Device already verified, but keys do NOT MATCH!": "WARNING: Device already verified, but keys do NOT MATCH!", diff --git a/src/i18n/strings/en_US.json b/src/i18n/strings/en_US.json index 5cdfd65d27..b2da44c2a6 100644 --- a/src/i18n/strings/en_US.json +++ b/src/i18n/strings/en_US.json @@ -576,6 +576,8 @@ "VoIP conference finished.": "VoIP conference finished.", "VoIP conference started.": "VoIP conference started.", "VoIP is unsupported": "VoIP is unsupported", + "(call failed to connect)": "(call failed to connect)", + "(unknown failure)": "(unknown failure)", "(warning: cannot be disabled again!)": "(warning: cannot be disabled again!)", "Warning!": "Warning!", "WARNING: Device already verified, but keys do NOT MATCH!": "WARNING: Device already verified, but keys do NOT MATCH!", From 2bfad52b40a8dc64793c85cd2fe33b41f3cbb032 Mon Sep 17 00:00:00 2001 From: Will Hunt Date: Sat, 10 Jun 2017 14:35:11 +0100 Subject: [PATCH 2/3] Make unknown failures more helpful. --- src/TextForEvent.js | 8 ++++---- src/i18n/strings/en_EN.json | 2 +- src/i18n/strings/en_US.json | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/TextForEvent.js b/src/TextForEvent.js index 61e821d7cb..9521ac3a6a 100644 --- a/src/TextForEvent.js +++ b/src/TextForEvent.js @@ -145,15 +145,15 @@ function textForCallHangupEvent(event) { const eventContent = event.getContent(); let reason = ""; if(!MatrixClientPeg.get().supportsVoip()) { - reason = '(not supported by this browser)'; + reason = _t('(not supported by this browser)'); } else if(eventContent.reason) { if (eventContent.reason === "ice_failed") { - reason = "(call failed to connect)"; + reason = _t('(call failed to connect)'); } else { - reason = `(${eventContent.reason})`; + reason = _t('(unknown failure: %(reason)s)', {reason: eventContent.reason}); } } - return _t('%(senderName)s ended the call.', {senderName}) + ' ' + _t(reason); + return _t('%(senderName)s ended the call.', {senderName}) + ' ' + reason; } function textForCallInviteEvent(event) { diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json index ed931c917f..93c5f2cf94 100644 --- a/src/i18n/strings/en_EN.json +++ b/src/i18n/strings/en_EN.json @@ -638,7 +638,7 @@ "VoIP conference started.": "VoIP conference started.", "VoIP is unsupported": "VoIP is unsupported", "(call failed to connect)": "(call failed to connect)", - "(unknown failure)": "(unknown failure)", + "(unknown failure: %(reason)s)": "(unknown failure: %(reason)s)", "(warning: cannot be disabled again!)": "(warning: cannot be disabled again!)", "Warning!": "Warning!", "WARNING: Device already verified, but keys do NOT MATCH!": "WARNING: Device already verified, but keys do NOT MATCH!", diff --git a/src/i18n/strings/en_US.json b/src/i18n/strings/en_US.json index b2da44c2a6..9038253a9b 100644 --- a/src/i18n/strings/en_US.json +++ b/src/i18n/strings/en_US.json @@ -577,7 +577,7 @@ "VoIP conference started.": "VoIP conference started.", "VoIP is unsupported": "VoIP is unsupported", "(call failed to connect)": "(call failed to connect)", - "(unknown failure)": "(unknown failure)", + "(unknown failure: %(reason)s)": "(unknown failure: %(reason)s)", "(warning: cannot be disabled again!)": "(warning: cannot be disabled again!)", "Warning!": "Warning!", "WARNING: Device already verified, but keys do NOT MATCH!": "WARNING: Device already verified, but keys do NOT MATCH!", From cbcca78c400017aea2c2e41c03a05e17347955be Mon Sep 17 00:00:00 2001 From: Will Hunt Date: Sun, 11 Jun 2017 07:19:19 +0100 Subject: [PATCH 3/3] Add text for invite_timeout and fix message for ice_failed. --- src/TextForEvent.js | 14 ++++++++------ src/i18n/strings/en_EN.json | 3 ++- src/i18n/strings/en_US.json | 3 ++- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/TextForEvent.js b/src/TextForEvent.js index 9521ac3a6a..de12cec502 100644 --- a/src/TextForEvent.js +++ b/src/TextForEvent.js @@ -145,13 +145,15 @@ function textForCallHangupEvent(event) { const eventContent = event.getContent(); let reason = ""; if(!MatrixClientPeg.get().supportsVoip()) { - reason = _t('(not supported by this browser)'); + reason = _t('(not supported by this browser)'); } else if(eventContent.reason) { - if (eventContent.reason === "ice_failed") { - reason = _t('(call failed to connect)'); - } else { - reason = _t('(unknown failure: %(reason)s)', {reason: eventContent.reason}); - } + if (eventContent.reason === "ice_failed") { + reason = _t('(could not connect media)'); + } else if (eventContent.reason === "invite_timeout") { + reason = _t('(no answer)'); + } else { + reason = _t('(unknown failure: %(reason)s)', {reason: eventContent.reason}); + } } return _t('%(senderName)s ended the call.', {senderName}) + ' ' + reason; } diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json index 93c5f2cf94..97e51c9613 100644 --- a/src/i18n/strings/en_EN.json +++ b/src/i18n/strings/en_EN.json @@ -637,7 +637,8 @@ "VoIP conference finished.": "VoIP conference finished.", "VoIP conference started.": "VoIP conference started.", "VoIP is unsupported": "VoIP is unsupported", - "(call failed to connect)": "(call failed to connect)", + "(could not connect media)": "(could not connect media)", + "(no answer)": "(no answer)", "(unknown failure: %(reason)s)": "(unknown failure: %(reason)s)", "(warning: cannot be disabled again!)": "(warning: cannot be disabled again!)", "Warning!": "Warning!", diff --git a/src/i18n/strings/en_US.json b/src/i18n/strings/en_US.json index 9038253a9b..580cb4d605 100644 --- a/src/i18n/strings/en_US.json +++ b/src/i18n/strings/en_US.json @@ -576,7 +576,8 @@ "VoIP conference finished.": "VoIP conference finished.", "VoIP conference started.": "VoIP conference started.", "VoIP is unsupported": "VoIP is unsupported", - "(call failed to connect)": "(call failed to connect)", + "(could not connect media)": "(could not connect media)", + "(no answer)": "(no answer)", "(unknown failure: %(reason)s)": "(unknown failure: %(reason)s)", "(warning: cannot be disabled again!)": "(warning: cannot be disabled again!)", "Warning!": "Warning!",