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

Migration of Favorites and Hometab to ES6 modules

This commit is contained in:
Cameron 2020-07-26 11:29:26 +01:00
parent 287cc06963
commit 3658b4471a
4 changed files with 97 additions and 82 deletions

View file

@ -1,27 +1,23 @@
define(['userSettings', 'loading', 'connectionManager', 'apphost', 'layoutManager', 'focusManager', 'homeSections', 'emby-itemscontainer'], function (userSettings, loading, connectionManager, appHost, layoutManager, focusManager, homeSections) {
'use strict';
import * as userSettings from 'userSettings';
import loading from 'loading';
import connectionManager from 'connectionManager';
import appHost from 'apphost';
import layoutManager from 'layoutManager';
import focusManager from 'focusManager';
import homeSections from 'homeSections';
import 'emby-itemscontainer';
function HomeTab(view, params) {
class HomeTab {
constructor(view, params) {
this.view = view;
this.params = params;
this.apiClient = connectionManager.currentApiClient();
this.sectionsContainer = view.querySelector('.sections');
view.querySelector('.sections').addEventListener('settingschange', onHomeScreenSettingsChanged.bind(this));
}
function onHomeScreenSettingsChanged() {
this.sectionsRendered = false;
if (!this.paused) {
this.onResume({
refresh: true
});
}
}
HomeTab.prototype.onResume = function (options) {
onResume(options) {
if (this.sectionsRendered) {
var sectionsContainer = this.sectionsContainer;
const sectionsContainer = this.sectionsContainer;
if (sectionsContainer) {
return homeSections.resume(sectionsContainer, options);
@ -31,8 +27,8 @@ define(['userSettings', 'loading', 'connectionManager', 'apphost', 'layoutManage
}
loading.show();
var view = this.view;
var apiClient = this.apiClient;
const view = this.view;
const apiClient = this.apiClient;
this.destroyHomeSections();
this.sectionsRendered = true;
return apiClient.getCurrentUser().then(function (user) {
@ -44,31 +40,38 @@ define(['userSettings', 'loading', 'connectionManager', 'apphost', 'layoutManage
loading.hide();
});
});
};
HomeTab.prototype.onPause = function () {
var sectionsContainer = this.sectionsContainer;
}
onPause() {
const sectionsContainer = this.sectionsContainer;
if (sectionsContainer) {
homeSections.pause(sectionsContainer);
}
};
HomeTab.prototype.destroy = function () {
}
destroy() {
this.view = null;
this.params = null;
this.apiClient = null;
this.destroyHomeSections();
this.sectionsContainer = null;
};
HomeTab.prototype.destroyHomeSections = function () {
var sectionsContainer = this.sectionsContainer;
}
destroyHomeSections() {
const sectionsContainer = this.sectionsContainer;
if (sectionsContainer) {
homeSections.destroySections(sectionsContainer);
}
};
}
}
return HomeTab;
});
function onHomeScreenSettingsChanged() {
this.sectionsRendered = false;
if (!this.paused) {
this.onResume({
refresh: true
});
}
}
export default HomeTab;