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

Merge remote-tracking branch 'upstream/master' into dead-code-society

This commit is contained in:
MrTimscampi 2020-07-26 18:28:32 +02:00
commit dc5af7d19f
54 changed files with 126 additions and 90 deletions

View file

@ -0,0 +1,52 @@
import PlaybackSettings from 'playbackSettings';
import * as userSettings from 'userSettings';
import autoFocuser from 'autoFocuser';
import 'listViewStyle';
/* eslint-disable indent */
// Shortcuts
const UserSettings = userSettings.UserSettings;
export default function (view, params) {
function onBeforeUnload(e) {
if (hasChanges) {
e.returnValue = 'You currently have unsaved changes. Are you sure you wish to leave?';
}
}
let settingsInstance;
let hasChanges;
const userId = params.userId || ApiClient.getCurrentUserId();
const currentSettings = userId === ApiClient.getCurrentUserId() ? userSettings : new UserSettings();
view.addEventListener('viewshow', function () {
window.addEventListener('beforeunload', onBeforeUnload);
if (settingsInstance) {
settingsInstance.loadData();
} else {
settingsInstance = new PlaybackSettings({
serverId: ApiClient.serverId(),
userId: userId,
element: view.querySelector('.settingsContainer'),
userSettings: currentSettings,
enableSaveButton: true,
enableSaveConfirmation: true,
autoFocus: autoFocuser.isEnabled()
});
}
});
view.addEventListener('change', function () {
hasChanges = true;
});
view.addEventListener('viewdestroy', function () {
if (settingsInstance) {
settingsInstance.destroy();
settingsInstance = null;
}
});
}
/* eslint-enable indent */