Skip to content

Commit

Permalink
Code cleanup based on review
Browse files Browse the repository at this point in the history
  • Loading branch information
1hitsong committed Oct 28, 2023
1 parent f3c0437 commit 16ccfe2
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 9 deletions.
4 changes: 0 additions & 4 deletions source/ShowScenes.brs
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@ function LoginFlow()
else
print "Success! Auth token is still valid"
session.user.Login(currentUser, true)
session.user.LoadUserPreferences()
LoadUserAbilities()
return true
end if
Expand All @@ -132,7 +131,6 @@ function LoginFlow()
if isValid(userData)
print "login success!"
session.user.Login(userData, true)
session.user.LoadUserPreferences()
LoadUserAbilities()
return true
else
Expand Down Expand Up @@ -175,7 +173,6 @@ function LoginFlow()
if isValid(userData)
print "login success!"
session.user.Login(userData, true)
session.user.LoadUserPreferences()
LoadUserAbilities()
return true
else
Expand All @@ -201,7 +198,6 @@ function LoginFlow()
goto start_login
end if

session.user.LoadUserPreferences()
LoadUserAbilities()
m.global.sceneManager.callFunc("clearScenes")

Expand Down
2 changes: 1 addition & 1 deletion source/api/sdk.bs
Original file line number Diff line number Diff line change
Expand Up @@ -1374,7 +1374,7 @@ namespace api
end function

' Gets a list of sessions.
function Get(params = {} as object)
function Get(params = { "deviceId": m.global.device.serverDeviceName } as object)
req = APIRequest("/sessions", params)
return getJson(req)
end function
Expand Down
2 changes: 1 addition & 1 deletion source/utils/globals.brs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ sub SaveDeviceToGlobal()
uuid: deviceInfo.GetRandomUUID(),
name: displayName,
friendlyName: filteredFriendly,
serverDeviceName: "",
serverDeviceName: deviceInfo.getChannelClientID(),
model: deviceInfo.GetModel(),
modelType: deviceInfo.GetModelType(),
modelDetails: deviceInfo.GetModelDetails(),
Expand Down
16 changes: 13 additions & 3 deletions source/utils/session.bs
Original file line number Diff line number Diff line change
Expand Up @@ -173,16 +173,23 @@ namespace session
set_user_setting("token", tmpSession.user.authToken)
set_user_setting("username", tmpSession.user.name)
end if

session.user.LoadUserPreferences()
end sub

' Load and parse Display Settings from server
sub LoadUserPreferences()
' Save device id so we don't calculate it every time we need it
' Sets the global service device name value used by the API
sub SetServerDeviceName()
if isValid(m.global.session.user) and isValid(m.global.session.user.friendlyName)
m.global.device.serverDeviceName = m.global.device.id + m.global.session.user.friendlyName
else
m.global.device.serverDeviceName = m.global.device.id
end if
end sub

' Load and parse Display Settings from server
sub LoadUserPreferences()
' Save device id so we don't calculate it every time we need it
session.user.SetServerDeviceName()

id = m.global.session.user.id
' Currently using client "emby", which is what website uses so we get same Display prefs as web.
Expand Down Expand Up @@ -344,6 +351,9 @@ namespace session
session.user.settings.Save(item, get_setting(item))
end if
end for

' Reset server device name state
session.user.SetServerDeviceName()
end sub

' Saves the user setting to the global session.
Expand Down

0 comments on commit 16ccfe2

Please sign in to comment.