Show reason for a call hanging up unexpectedly.

This commit is contained in:
Will Hunt 2017-06-10 14:26:27 +01:00
parent 3b7ce49eab
commit 18490377f8
3 changed files with 20 additions and 7 deletions

View file

@ -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 See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
import MatrixClientPeg from "./MatrixClientPeg";
var MatrixClientPeg = require("./MatrixClientPeg"); import CallHandler from "./CallHandler";
var CallHandler = require("./CallHandler");
import { _t } from './languageHandler'; import { _t } from './languageHandler';
import * as Roles from './Roles'; import * as Roles from './Roles';
@ -117,7 +116,7 @@ function textForTopicEvent(ev) {
function textForRoomNameEvent(ev) { function textForRoomNameEvent(ev) {
var senderDisplayName = ev.sender && ev.sender.name ? ev.sender.name : ev.getSender(); var senderDisplayName = ev.sender && ev.sender.name ? ev.sender.name : ev.getSender();
if (!ev.getContent().name || ev.getContent().name.trim().length === 0) { if (!ev.getContent().name || ev.getContent().name.trim().length === 0) {
return _t('%(senderDisplayName)s removed the room name.', {senderDisplayName: senderDisplayName}); return _t('%(senderDisplayName)s removed the room name.', {senderDisplayName: senderDisplayName});
} }
@ -142,9 +141,19 @@ function textForCallAnswerEvent(event) {
} }
function textForCallHangupEvent(event) { function textForCallHangupEvent(event) {
var senderName = event.sender ? event.sender.name : _t('Someone'); const senderName = event.sender ? event.sender.name : _t('Someone');
var supported = MatrixClientPeg.get().supportsVoip() ? "" : _t('(not supported by this browser)'); const eventContent = event.getContent();
return _t('%(senderName)s ended the call.', {senderName: senderName}) + ' ' + supported; 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) { function textForCallInviteEvent(event) {

View file

@ -637,6 +637,8 @@
"VoIP conference finished.": "VoIP conference finished.", "VoIP conference finished.": "VoIP conference finished.",
"VoIP conference started.": "VoIP conference started.", "VoIP conference started.": "VoIP conference started.",
"VoIP is unsupported": "VoIP is unsupported", "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: cannot be disabled again!)": "(warning: cannot be disabled again!)",
"Warning!": "Warning!", "Warning!": "Warning!",
"WARNING: Device already verified, but keys do NOT MATCH!": "WARNING: Device already verified, but keys do NOT MATCH!", "WARNING: Device already verified, but keys do NOT MATCH!": "WARNING: Device already verified, but keys do NOT MATCH!",

View file

@ -576,6 +576,8 @@
"VoIP conference finished.": "VoIP conference finished.", "VoIP conference finished.": "VoIP conference finished.",
"VoIP conference started.": "VoIP conference started.", "VoIP conference started.": "VoIP conference started.",
"VoIP is unsupported": "VoIP is unsupported", "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: cannot be disabled again!)": "(warning: cannot be disabled again!)",
"Warning!": "Warning!", "Warning!": "Warning!",
"WARNING: Device already verified, but keys do NOT MATCH!": "WARNING: Device already verified, but keys do NOT MATCH!", "WARNING: Device already verified, but keys do NOT MATCH!": "WARNING: Device already verified, but keys do NOT MATCH!",