1
0
Fork 0
mirror of https://github.com/jellyfin/jellyfin-web synced 2025-03-30 19:56:21 +00:00

Merge pull request #720 from dmitrylyzo/exit_on_back

Add app exit on "Go back"
This commit is contained in:
dkanada 2020-01-31 01:05:15 +09:00 committed by GitHub
commit 1a3037229d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 67 additions and 14 deletions

View file

@ -545,13 +545,18 @@ define(['loading', 'globalize', 'events', 'viewManager', 'layoutManager', 'skinM
page.back();
}
/**
* Pages of "no return" (when "Go back" should behave differently, probably quitting the application).
*/
var startPages = ['home', 'login', 'selectserver'];
function canGoBack() {
var curr = current();
if (!curr) {
return false;
}
if (curr.type === 'home') {
if (!document.querySelector('.dialogContainer') && startPages.indexOf(curr.type) !== -1) {
return false;
}
return page.canGoBack();

View file

@ -299,6 +299,52 @@ define(["appSettings", "browser", "events", "htmlMediaHelper"], function (appSet
return features;
}();
/**
* 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";
@ -314,16 +360,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) {