Add exit on "Go back"

This commit is contained in:
Dmitry Lyzo 2020-01-21 12:51:33 +03:00
parent 02f6928fcd
commit 60e64f8a58
5 changed files with 58 additions and 12 deletions

View File

@ -551,7 +551,7 @@ define(['loading', 'globalize', 'events', 'viewManager', 'layoutManager', 'skinM
return false;
}
if (curr.type === 'home') {
if (!document.querySelector('.dialogContainer') && curr.type === 'home') {
return false;
}
return page.canGoBack();

View File

@ -311,6 +311,52 @@ define(["appSettings", "browser", "events", "htmlMediaHelper"], function (appSet
});
}
/**
* Do exit according to platform
*/
function doExit() {
try {
if (window.NativeShell) {
window.NativeShell.AppHost.exit();
} else if (browser.tizen) {
tizen.application.getCurrentApplication().exit();
} else if (browser.web0s) {
webOS.platformBack();
} else {
window.close();
}
} catch (err) {
console.log("error closing application: " + err);
}
}
var exitPromise;
/**
* Ask user for exit
*/
function askForExit() {
if (!!exitPromise) {
return;
}
require(["actionsheet"], function (actionsheet) {
exitPromise = actionsheet.show({
title: Globalize.translate("MessageConfirmAppExit"),
items: [
{id: "yes", name: Globalize.translate("Yes")},
{id: "no", name: Globalize.translate("No")}
]
}).then(function (value) {
if (value === "yes") {
doExit();
}
}).finally(function () {
exitPromise = null;
});
});
}
var deviceId;
var deviceName;
var appName = "Jellyfin Web";
@ -326,16 +372,10 @@ define(["appSettings", "browser", "events", "htmlMediaHelper"], function (appSet
alert("setWindowState is not supported and should not be called");
},
exit: function () {
if (window.NativeShell) {
window.NativeShell.AppHost.exit();
} else if (browser.tizen) {
try {
tizen.application.getCurrentApplication().exit();
} catch (err) {
console.log("error closing application: " + err);
}
if (!!window.appMode && browser.tizen) {
askForExit();
} else {
window.close();
doExit();
}
},
supports: function (command) {

View File

@ -1,4 +1,4 @@
define(['playbackManager', 'focusManager', 'appRouter', 'dom'], function (playbackManager, focusManager, appRouter, dom) {
define(['playbackManager', 'focusManager', 'appRouter', 'dom', 'apphost'], function (playbackManager, focusManager, appRouter, dom, appHost) {
'use strict';
var lastInputTime = new Date().getTime();
@ -98,7 +98,11 @@ define(['playbackManager', 'focusManager', 'appRouter', 'dom'], function (playba
appRouter.showSettings();
break;
case 'back':
appRouter.back();
if (appRouter.canGoBack()) {
appRouter.back();
} else if (appHost.supports('exit')) {
appHost.exit();
}
break;
case 'forward':
break;

View File

@ -945,6 +945,7 @@
"MessageAlreadyInstalled": "This version is already installed.",
"MessageAreYouSureDeleteSubtitles": "Are you sure you wish to delete this subtitle file?",
"MessageAreYouSureYouWishToRemoveMediaFolder": "Are you sure you wish to remove this media folder?",
"MessageConfirmAppExit": "Do you want to exit?",
"MessageConfirmDeleteGuideProvider": "Are you sure you wish to delete this guide provider?",
"MessageConfirmDeleteTunerDevice": "Are you sure you wish to delete this device?",
"MessageConfirmProfileDeletion": "Are you sure you wish to delete this profile?",

View File

@ -890,6 +890,7 @@
"MessageAlreadyInstalled": "Данная версия уже установлена.",
"MessageAreYouSureDeleteSubtitles": "Вы действительно хотите удалить данный файл субитров?",
"MessageAreYouSureYouWishToRemoveMediaFolder": "Вы действительно хотите изъять данную медиапапку?",
"MessageConfirmAppExit": "Вы хотите выйти?",
"MessageConfirmDeleteGuideProvider": "Вы действительно хотите удалить данного поставщика телегида?",
"MessageConfirmDeleteTunerDevice": "Вы действительно хотите удалить данное устройство?",
"MessageConfirmProfileDeletion": "Вы действительно хотите удалить данный профиль?",