2020-05-04 12:44:12 +02:00
|
|
|
define(['userSettings', 'loading', 'connectionManager', 'apphost', 'layoutManager', 'focusManager', 'homeSections', 'emby-itemscontainer'], function (userSettings, loading, connectionManager, appHost, layoutManager, focusManager, homeSections) {
|
|
|
|
'use strict';
|
2018-10-23 01:05:09 +03:00
|
|
|
|
|
|
|
function HomeTab(view, params) {
|
2019-11-06 13:43:39 +03:00
|
|
|
this.view = view;
|
|
|
|
this.params = params;
|
|
|
|
this.apiClient = connectionManager.currentApiClient();
|
2020-05-04 12:44:12 +02:00
|
|
|
this.sectionsContainer = view.querySelector('.sections');
|
|
|
|
view.querySelector('.sections').addEventListener('settingschange', onHomeScreenSettingsChanged.bind(this));
|
2018-10-23 01:05:09 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
function onHomeScreenSettingsChanged() {
|
2019-11-06 13:43:39 +03:00
|
|
|
this.sectionsRendered = false;
|
|
|
|
|
|
|
|
if (!this.paused) {
|
|
|
|
this.onResume({
|
|
|
|
refresh: true
|
|
|
|
});
|
|
|
|
}
|
2018-10-23 01:05:09 +03:00
|
|
|
}
|
2019-11-06 13:43:39 +03:00
|
|
|
|
|
|
|
HomeTab.prototype.onResume = function (options) {
|
2018-10-23 01:05:09 +03:00
|
|
|
if (this.sectionsRendered) {
|
|
|
|
var sectionsContainer = this.sectionsContainer;
|
2019-11-06 13:43:39 +03:00
|
|
|
|
|
|
|
if (sectionsContainer) {
|
|
|
|
return homeSections.resume(sectionsContainer, options);
|
|
|
|
}
|
|
|
|
|
|
|
|
return Promise.resolve();
|
2018-10-23 01:05:09 +03:00
|
|
|
}
|
2019-11-06 13:43:39 +03:00
|
|
|
|
2018-10-23 01:05:09 +03:00
|
|
|
loading.show();
|
2019-11-06 13:43:39 +03:00
|
|
|
var view = this.view;
|
|
|
|
var apiClient = this.apiClient;
|
|
|
|
this.destroyHomeSections();
|
|
|
|
this.sectionsRendered = true;
|
|
|
|
return apiClient.getCurrentUser().then(function (user) {
|
2020-05-04 12:44:12 +02:00
|
|
|
return homeSections.loadSections(view.querySelector('.sections'), apiClient, user, userSettings).then(function () {
|
2019-11-06 13:43:39 +03:00
|
|
|
if (options.autoFocus) {
|
|
|
|
focusManager.autoFocus(view);
|
|
|
|
}
|
|
|
|
|
|
|
|
loading.hide();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
HomeTab.prototype.onPause = function () {
|
2018-10-23 01:05:09 +03:00
|
|
|
var sectionsContainer = this.sectionsContainer;
|
2019-11-06 13:43:39 +03:00
|
|
|
|
|
|
|
if (sectionsContainer) {
|
|
|
|
homeSections.pause(sectionsContainer);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
HomeTab.prototype.destroy = function () {
|
|
|
|
this.view = null;
|
|
|
|
this.params = null;
|
|
|
|
this.apiClient = null;
|
|
|
|
this.destroyHomeSections();
|
|
|
|
this.sectionsContainer = null;
|
|
|
|
};
|
|
|
|
|
|
|
|
HomeTab.prototype.destroyHomeSections = function () {
|
2018-10-23 01:05:09 +03:00
|
|
|
var sectionsContainer = this.sectionsContainer;
|
2019-11-06 13:43:39 +03:00
|
|
|
|
|
|
|
if (sectionsContainer) {
|
|
|
|
homeSections.destroySections(sectionsContainer);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
return HomeTab;
|
|
|
|
});
|