dashboard-ui/home/hometab.js
2023-08-31 15:30:17 +02:00

1 line
2.7 KiB
JavaScript

define(["exports","./../modules/tabbedview/basetab.js","./../modules/loading/loading.js","./../modules/homesections/homesections.js","./../modules/emby-elements/emby-itemscontainer/emby-itemscontainer.js","./../modules/emby-apiclient/connectionmanager.js"],function(_exports,_basetab,_loading,_homesections,_embyItemscontainer,_connectionmanager){function HomeTab(view,params){_basetab.default.apply(this,arguments),this.view=view,this.params=params,this.apiClient=_connectionmanager.default.currentApiClient(),this.sectionsContainer=view.querySelector(".sections"),view.querySelector(".sections").addEventListener("settingschange",function(){this.sectionsRendered=!1,this.paused||this.onResume({refresh:!0})}.bind(this))}function autoFocus(){!this.instance.autoFocus()&&this.retries<20?(this.retries++,setTimeout(autoFocus.bind(this),100)):(this.view=null,this.retries=null)}Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.default=void 0,Object.assign(HomeTab.prototype,_basetab.default.prototype),HomeTab.prototype.supportsFocusPreview=function(){return!0},HomeTab.prototype.onResume=function(options){var sectionsContainer;if(_basetab.default.prototype.onResume.apply(this,arguments),this.sectionsRendered)return(sectionsContainer=this.sectionsContainer)?_homesections.default.resume(sectionsContainer,options):Promise.resolve();this.refresh(options)},HomeTab.prototype.refresh=function(options){_loading.default.show();var view=this.view,apiClient=this.apiClient,instance=(this.destroyHomeSections(),this.sectionsRendered=!0,this);return apiClient.getCurrentUser().then(function(user){return _homesections.default.loadSections({element:view.querySelector(".sections"),apiClient:apiClient,user:user,requestedItemFields:instance.getRequestedItemFields(),requestedImageTypes:instance.getRequestedImageTypes(),enableFocusPreview:instance.enableFocusPreview()}).then(function(){for(var itemsContainers=view.querySelectorAll(".itemsContainer"),i=0,length=itemsContainers.length;i<length;i++)instance.addFocusBehavior(itemsContainers[i]);options.autoFocus&&!instance.autoFocus()&&setTimeout(autoFocus.bind({retries:0,instance:instance}),100),_loading.default.hide()})})},HomeTab.prototype.onPause=function(){_basetab.default.prototype.onPause.apply(this,arguments);var sectionsContainer=this.sectionsContainer;sectionsContainer&&_homesections.default.pause(sectionsContainer)},HomeTab.prototype.destroy=function(){_basetab.default.prototype.destroy.apply(this,arguments),this.view=null,this.params=null,this.apiClient=null,this.destroyHomeSections(),this.sectionsContainer=null},HomeTab.prototype.destroyHomeSections=function(){var sectionsContainer=this.sectionsContainer;sectionsContainer&&(sectionsContainer.innerHTML="")},_exports.default=HomeTab});