1 line
13 KiB
JavaScript
1 line
13 KiB
JavaScript
|
|
import appSettings from"./../appsettings.js";import events from"./../../emby-apiclient/events.js";function onSaveTimeout(){this.saveTimeout=null,this.currentApiClient.updateDisplayPreferences(this.displayPrefs,this.currentUserId)}function saveServerPreferences(instance,name,value){var obj;instance.supportsPartialSave?((obj={})[name]=value,instance.currentApiClient.updatePartialDisplayPreferences(obj,instance.currentUserId)):(instance.saveTimeout&&clearTimeout(instance.saveTimeout),instance.saveTimeout=setTimeout(onSaveTimeout.bind(instance),50))}function UserSettings(){}function getHomeSection(instance,index){let section=instance.get("homesection"+index)||instance.getDefaultHomeScreenSection(index);return"folders"===section?section=instance.getDefaultHomeScreenSection(0):"onnow"===section?section="livetv":"librarytiles"!==section&&"smalllibrarytiles-automobile"!==section&&"librarytiles-automobile"!==section||(section="smalllibrarytiles"),section}UserSettings.prototype.setUserInfo=function(userId,apiClient){if(this.saveTimeout&&clearTimeout(this.saveTimeout),this.currentUserId=userId,this.currentApiClient=apiClient,this.supportsPartialSave=apiClient?.isMinServerVersion("4.9.0.23"),!userId)return this.displayPrefs=null,Promise.resolve();let self=this;return apiClient.getDisplayPreferences(userId).then(function(result){self.displayPrefs=result,events.trigger(self,"load")})},UserSettings.prototype.getData=function(){return this.displayPrefs},UserSettings.prototype.importFrom=function(instance){this.displayPrefs=instance.getData()},UserSettings.prototype.set=function(name,value,enableOnServer){var currentValue,userId=this.currentUserId;if(userId)return currentValue=this.get(name,enableOnServer),userId=appSettings.set(name,value=null==value?null:value,userId),!1!==enableOnServer&&this.displayPrefs&&(enableOnServer=null==value?value:value.toString(),this.displayPrefs[name]=enableOnServer,saveServerPreferences(this,name,enableOnServer)),currentValue!==value&&events.trigger(this,"change",[name,value]),userId;throw new Error("userId cannot be null")},UserSettings.prototype.remove=function(name,enableOnServer){return this.set(name,null,enableOnServer)},UserSettings.prototype.get=function(name,enableOnServer){var userId=this.currentUserId;return userId?!1!==enableOnServer&&this.displayPrefs?this.displayPrefs[name]:appSettings.get(name,userId):null},UserSettings.prototype.serverConfig=function(config){var apiClient=this.currentApiClient;return config?apiClient.updateUserConfiguration(this.currentUserId,config):apiClient.getUser(this.currentUserId).then(function(user){return user.Configuration})},UserSettings.prototype.enableCinemaMode=function(val){return null!=val?this.set("enableCinemaMode",val.toString(),!1):!(val=this.get("enableCinemaMode",!1))||"false"!==val},UserSettings.prototype.enableNextVideoInfoOverlay=function(val){return null!=val?this.set("enableNextVideoInfoOverlay",val.toString()):"false"!==(val=this.get("enableNextVideoInfoOverlay"))},UserSettings.prototype.getEnableLogoAsTitle=function(displayLanguage){var val=this.get("enableLogoAsTitle");return val?"true"===val:displayLanguage&&displayLanguage.toLowerCase().startsWith("en")},UserSettings.prototype.setEnableLogoAsTitle=function(val){return this.set("enableLogoAsTitle",val.toString())},UserSettings.prototype.enableThemeSongs=function(val){return null!=val?this.set("enableThemeSongs",val.toString(),!1):"false"!==(val=this.get("enableThemeSongs",!1))},UserSettings.prototype.groupCollectionItems=function(val){return null!=val?this.set("groupCollectionItems",val.toString(),!0):"false"!==(val=this.get("groupCollectionItems",!0))},UserSettings.prototype.enableThemeVideos=function(val){return null!=val?this.set("enableThemeVideos",val.toString(),!1):!!(val=this.get("enableThemeVideos",!1))&&"false"!==val},UserSettings.prototype.hideMediaTransportButtons=function(val){return null!=val?this.set("hideMediaTransportButtons",val.toString(),!1):this.get("hideMediaTransportButtons",!1)||"auto"},UserSettings.prototype.enableHomescreenFocusPreviews=function(val){return null!=val?
|