create global rememberme setting

This commit is contained in:
Charles Ewert 2023-09-14 17:51:41 -04:00
parent b9359b8f51
commit 50020a3f20
5 changed files with 85 additions and 4 deletions

View File

@ -54,7 +54,9 @@ function setPreference(key as string, value as string)
end function end function
sub setActive() sub setActive()
set_setting("active_user", m.top.id) if m.global.session.user.settings["global.rememberme"]
set_setting("active_user", m.top.id)
end if
end sub end sub
sub setServer(hostname as string) sub setServer(hostname as string)

View File

@ -1,6 +1,7 @@
import "pkg:/source/utils/config.brs" import "pkg:/source/utils/config.brs"
import "pkg:/source/utils/misc.brs" import "pkg:/source/utils/misc.brs"
import "pkg:/source/roku_modules/log/LogMixin.brs" import "pkg:/source/roku_modules/log/LogMixin.brs"
import "pkg:/source/api/sdk.bs"
sub init() sub init()
m.log = log.Logger("Settings") m.log = log.Logger("Settings")
@ -160,14 +161,40 @@ end sub
sub boolSettingChanged() sub boolSettingChanged()
if m.boolSetting.focusedChild = invalid then return if m.boolSetting.focusedChild = invalid then return
selectedSetting = m.userLocation.peek().children[m.settingsMenu.itemFocused] selectedSetting = m.userLocation.peek().children[m.settingsMenu.itemFocused]
if m.boolSetting.checkedItem if m.boolSetting.checkedItem
set_user_setting(selectedSetting.settingName, "true") session.user.settings.Save(selectedSetting.settingName, "true")
if Left(selectedSetting.settingName, 7) = "global."
' global user setting
' save to main registry block
set_setting(selectedSetting.settingName, "true")
' setting specific triggers
if selectedSetting.settingName = "global.rememberme"
print "m.global.session.user.id=", m.global.session.user.id
set_setting("active_user", m.global.session.user.id)
end if
else
' regular user setting
' save to user specific registry block
set_user_setting(selectedSetting.settingName, "true")
end if
else else
set_user_setting(selectedSetting.settingName, "false") session.user.settings.Save(selectedSetting.settingName, "false")
if Left(selectedSetting.settingName, 7) = "global."
' global user setting
' save to main registry block
set_setting(selectedSetting.settingName, "false")
' setting specific triggers
if selectedSetting.settingName = "global.rememberme"
unset_setting("active_user")
end if
else
' regular user setting
' save to user specific registry block
set_user_setting(selectedSetting.settingName, "false")
end if
end if end if
end sub end sub

View File

@ -1208,5 +1208,25 @@
<translation>Disable the HEVC codec on this device. This may improve playback for some devices (ultra).</translation> <translation>Disable the HEVC codec on this device. This may improve playback for some devices (ultra).</translation>
<extracomment>User Setting - Setting description</extracomment> <extracomment>User Setting - Setting description</extracomment>
</message> </message>
<message>
<source>Global</source>
<translation>Global</translation>
<extracomment>User Setting - Setting title</extracomment>
</message>
<message>
<source>Global settings that affect everyone that uses this Roku device.</source>
<translation>Global settings that affect everyone that uses this Roku device.</translation>
<extracomment>User Setting - Setting description</extracomment>
</message>
<message>
<source>Remember Me?</source>
<translation>Remember Me?</translation>
<extracomment>User Setting - Setting title</extracomment>
</message>
<message>
<source>Remember the currently logged in user and try to log them in again next time you start the Jellyfin app.</source>
<translation>Remember the currently logged in user and try to log them in again next time you start the Jellyfin app.</translation>
<extracomment>User Setting - Setting description</extracomment>
</message>
</context> </context>
</TS> </TS>

View File

@ -1,4 +1,18 @@
[ [
{
"title": "Global",
"description": "Global settings that affect everyone that uses this Roku device.",
"children": [
{
"title": "Remember Me?",
"description": "Remember the currently logged in user and try to log them in again next time you start the Jellyfin app.",
"settingName": "global.rememberme",
"type": "bool",
"default": "false"
}
]
},
{ {
"title": "Playback", "title": "Playback",
"description": "Settings relating to playback and supported codec and media types.", "description": "Settings relating to playback and supported codec and media types.",

View File

@ -151,6 +151,10 @@ namespace session
if m.global.app.isDev if m.global.app.isDev
print "m.global.session.user.settings = ", m.global.session.user.settings print "m.global.session.user.settings = ", m.global.session.user.settings
end if end if
if m.global.session.user.settings["global.rememberme"]
set_user_setting("token", tmpSession.user.authToken)
end if
end sub end sub
' Empty the global user session array and reload defaults ' Empty the global user session array and reload defaults
@ -228,6 +232,20 @@ namespace session
end for end for
end if end if
end for end for
' load globals
session.user.settings.LoadGlobals()
end sub
' Grab global vars from registry and overwrite defaults
sub LoadGlobals()
' search main registry block for all keys that start with "global."
jfRegistry = RegistryReadAll("Jellyfin")
for each item in jfRegistry
if Left(item, 7) = "global."
session.user.settings.Save(item, get_setting(item))
end if
end for
end sub end sub
' Saves the user setting to the global session. ' Saves the user setting to the global session.