Minor fixes for error dialogs

This commit is contained in:
tsareg 2016-05-27 14:01:43 +03:00
parent e257a3dfc9
commit ccdba03888
2 changed files with 25 additions and 16 deletions

View File

@ -1056,8 +1056,6 @@ export default {
this.useVideoStream(null);
this.videoSwitchInProgress = false;
console.error('failed to share local video', err);
APP.UI.showDeviceErrorDialog('camera', err);
});
}
},

View File

@ -1164,23 +1164,29 @@ UI.showDeviceErrorDialog = function (type, error) {
throw new Error("Invalid device type");
}
if (window.localStorage[type + "DoNotShowErrorAgain-" + error.name]
=== "true") {
if (error.name && error instanceof JitsiMeetJS.JitsiTrackError &&
window.localStorage[type + "DoNotShowErrorAgain-" + error.name]
=== "true") {
return;
}
let titleKey = error.name === TrackErrors.PERMISSION_DENIED
? "dialog.permissionDenied"
: "dialog.error",
errorMsg = JITSI_TRACK_ERROR_TO_MESSAGE_KEY_MAP[type][error.name],
doNotShowAgainMsg = "dialog.doNotShowWarningAgain",
errorMsg = JITSI_TRACK_ERROR_TO_MESSAGE_KEY_MAP[type][error.name] ||
JITSI_TRACK_ERROR_TO_MESSAGE_KEY_MAP[type][TrackErrors.GENERAL],
title = `<span data-i18n="${titleKey}"></span>`,
message = `
<h4 data-i18n="${errorMsg}"></h4>
<label>
<input type="checkbox" id="doNotShowWarningAgain">
<span data-i18n="${doNotShowAgainMsg}"></span>
</label>`;
message = "<h4 data-i18n='" + errorMsg + "'></h4>" +
(!JITSI_TRACK_ERROR_TO_MESSAGE_KEY_MAP[type][error.name]
&& error.message
? "<div>" + error.message + "</div>"
: "") +
"<label>" +
"<input type='checkbox' id='doNotShowWarningAgain'> " +
(error instanceof JitsiMeetJS.JitsiTrackError && error.name
? "<span data-i18n='dialog.doNotShowWarningAgain'></span>"
: "") +
"</label>";
messageHandler.openDialog(
title,
@ -1188,11 +1194,16 @@ UI.showDeviceErrorDialog = function (type, error) {
false,
{Ok: true},
function () {
let form = $.prompt.getPrompt(),
input = form.find("#doNotShowWarningAgain");
let form = $.prompt.getPrompt();
window.localStorage[type + "DoNotShowErrorAgain-" + error.name]
= input.prop("checked");
if (form) {
let input = form.find("#doNotShowWarningAgain");
if (input.length) {
window.localStorage[type + "DoNotShowErrorAgain-"
+ error.name] = input.prop("checked");
}
}
}
);