From bac572ae716f0fb5e716b22bc660f39a8b13c324 Mon Sep 17 00:00:00 2001 From: Charles Ewert Date: Tue, 30 Jul 2024 14:03:50 -0400 Subject: [PATCH 1/2] save useEpisodeImagesInNextUpAndResume from web client to session --- source/utils/misc.bs | 15 +++++++++++++++ source/utils/session.bs | 33 +++++++++++++++++---------------- 2 files changed, 32 insertions(+), 16 deletions(-) diff --git a/source/utils/misc.bs b/source/utils/misc.bs index 8af32c61f..24c44f569 100644 --- a/source/utils/misc.bs +++ b/source/utils/misc.bs @@ -584,3 +584,18 @@ function createOverhangUser() return userLabel end function + +' convert value to boolean and return value +function toBoolean(value as dynamic) as dynamic + if value = invalid then return invalid + if Type(value) = "Boolean" then return value + if Type(value) <> "String" then return value + + if value = "true" + return true + else if value = "false" + return false + else + return value + end if +end function diff --git a/source/utils/session.bs b/source/utils/session.bs index 497ff310b..20ff7a9b1 100644 --- a/source/utils/session.bs +++ b/source/utils/session.bs @@ -2,6 +2,7 @@ import "pkg:/source/api/userauth.bs" import "pkg:/source/api/baserequest.bs" import "pkg:/source/migrations.bs" +import "pkg:/source/utils/misc.bs" namespace session ' Initialize the global session array @@ -182,13 +183,6 @@ namespace session end if end for - if m.global.app.isDev - print "m.global.session.user = ", m.global.session.user - print "m.global.session.user.Configuration = ", m.global.session.user.Configuration - print "m.global.session.user.Policy = ", m.global.session.user.Policy - print "m.global.session.user.settings = ", m.global.session.user.settings - end if - set_user_setting("serverId", m.global.session.server.id) if saveCredentials @@ -204,6 +198,13 @@ namespace session session.user.SetServerDeviceName() ' Load user preferences from server session.user.LoadUserPreferences() + + if m.global.app.isDev + print "m.global.session.user = ", m.global.session.user + print "m.global.session.user.Configuration = ", m.global.session.user.Configuration + print "m.global.session.user.Policy = ", m.global.session.user.Policy + print "m.global.session.user.settings = ", m.global.session.user.settings + end if end sub ' Sets the global server device name value used by the API @@ -234,6 +235,14 @@ namespace session jsonResponse = getJson(resp) if isValid(jsonResponse) and isValid(jsonResponse.CustomPrefs) + ' save useEpisodeImagesInNextUpAndResume to global session + tmpSetting = jsonResponse.CustomPrefs.useEpisodeImagesInNextUpAndResume + if isValid(tmpSetting) + tmpConfig = m.global.session.user.Configuration + tmpConfig.AddReplace("useEpisodeImagesInNextUpAndResume", toBoolean(tmpSetting)) + session.user.Update("Configuration", tmpConfig) + end if + session.user.SaveUserHomeSections(jsonResponse.CustomPrefs) if isValid(jsonResponse.CustomPrefs["landing-livetv"]) @@ -414,16 +423,8 @@ namespace session sub Save(name as string, value as string) if name = invalid or value = invalid then return tmpSettingArray = m.global.session.user.settings - convertedValue = value - - ' convert to boolean - if value = "true" - convertedValue = true - else if value = "false" - convertedValue = false - end if - tmpSettingArray[name] = convertedValue + tmpSettingArray[name] = toBoolean(value) session.user.Update("settings", tmpSettingArray) end sub From cae2bea5810f245007b23e9d0053b1725c49f6ee Mon Sep 17 00:00:00 2001 From: Charles Ewert Date: Tue, 30 Jul 2024 14:42:41 -0400 Subject: [PATCH 2/2] create and implement episode image user setting --- components/home/HomeItem.bs | 11 +++++++++-- locale/en_US/translations.ts | 25 +++++++++++++++++++++++++ settings/settings.json | 21 +++++++++++++++++++++ 3 files changed, 55 insertions(+), 2 deletions(-) diff --git a/components/home/HomeItem.bs b/components/home/HomeItem.bs index c5546d5ab..b49031a15 100644 --- a/components/home/HomeItem.bs +++ b/components/home/HomeItem.bs @@ -146,9 +146,16 @@ sub itemContentChanged() drawProgressBar(itemData) end if - if itemData.usePoster = true + if localGlobal.session.user.settings["ui.general.episodeimagesnextup"] = "webclient" + tmpSetting = localGlobal.session.user.Configuration.useEpisodeImagesInNextUpAndResume + if isValid(tmpSetting) and tmpSetting + m.itemPoster.uri = itemData.thumbnailURL + else + m.itemPoster.uri = itemData.widePosterURL + end if + else if localGlobal.session.user.settings["ui.general.episodeimagesnextup"] = "show" m.itemPoster.uri = itemData.widePosterURL - else + else if localGlobal.session.user.settings["ui.general.episodeimagesnextup"] = "episode" m.itemPoster.uri = itemData.thumbnailURL end if diff --git a/locale/en_US/translations.ts b/locale/en_US/translations.ts index fe5666d25..7ba3844b8 100644 --- a/locale/en_US/translations.ts +++ b/locale/en_US/translations.ts @@ -1286,5 +1286,30 @@ Show already watched episodes in 'Next Up' sections. User Setting - Setting description + + Episode Images Next Up + Episode Images Next Up + User Setting - Setting title + + + What type of images to use for Episodes shown in the 'Next Up' and 'Continue Watching' sections. + What type of images to use for Episodes shown in the 'Next Up' and 'Continue Watching' sections. + User Setting - Setting description + + + Use Web Client Setting + Use Web Client Setting + User Setting - Setting option title + + + Use Episode Image + Use Episode Image + User Setting - Setting option title + + + Use Show Image + Use Show Image + User Setting - Setting option title + diff --git a/settings/settings.json b/settings/settings.json index 6f5e15c00..99e053715 100644 --- a/settings/settings.json +++ b/settings/settings.json @@ -220,6 +220,27 @@ "title": "General", "description": "Settings relating to the appearance of the Home screen and the program in general.", "children": [ + { + "title": "Episode Images Next Up", + "description": "What type of images to use for Episodes shown in the 'Next Up' and 'Continue Watching' sections.", + "settingName": "ui.general.episodeimagesnextup", + "type": "radio", + "default": "webclient", + "options": [ + { + "title": "Use Web Client Setting", + "id": "webclient" + }, + { + "title": "Use Episode Image", + "id": "episode" + }, + { + "title": "Use Show Image", + "id": "show" + } + ] + }, { "title": "Hide Clock", "description": "Hide all clocks in Jellyfin. Jellyfin will need to be closed and reopened for changes to take effect.",