Skip to content

Commit ae34d58

Browse files
committed
Update code docs
1 parent 5268514 commit ae34d58

1 file changed

Lines changed: 27 additions & 7 deletions

File tree

docs/components_JROverhang.bs.html

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,17 +35,21 @@
3535
sub currentUserChanged()
3636
m.user.text = m.top.currentUser
3737

38-
if not isValid(m.userImagePoster)
39-
m.userImagePoster = createUserImage()
40-
end if
41-
4238
if m.top.currentUser = ""
39+
' remove the user image node if it exists
4340
userImage = m.userGroup.findNode("userImage")
4441
if isValid(userImage)
4542
m.userGroup.removeChild(userImage)
4643
end if
44+
' remove cached user image if it exists
45+
m.userImage = invalid
4746
else
48-
m.userGroup.insertChild(m.userImagePoster, 0)
47+
' cache the user image node if needed
48+
if not isValid(m.userImage)
49+
m.userImage = createUserImage()
50+
end if
51+
' add the user image node to the overhang
52+
m.userGroup.insertChild(m.userImage, 0)
4953
end if
5054
end sub
5155

@@ -62,10 +66,26 @@
6266

6367
userImage = createObject("roSGNode", "Poster")
6468
userImage.id = "userImage"
65-
userImage.uri = buildURL(Substitute("/Users/{0}/Images/Primary", m.global.session.user.id), imgParams)
6669
userImage.width = "36"
6770
userImage.height = "36"
68-
userImage.translation = "[0, -2]"
71+
72+
if isValid(imgTag) and imgTag <> ""
73+
' reset defaults
74+
m.userGroup.itemSpacings = 15
75+
userImage.blendColor = "0xFFFFFFFF"
76+
77+
if m.global.session.server.url <> ""
78+
userImage.uri = buildURL(Substitute("/Users/{0}/Images/Primary", m.global.session.user.id), imgParams)
79+
else
80+
print "ERROR: No server URL set, cannot load user image"
81+
end if
82+
83+
else
84+
m.userGroup.itemSpacings = 9 ' account for default image padding
85+
userImage.blendColor = m.global.constants.colors.text_secondary
86+
87+
userImage.uri = "pkg:/images/icons/person_36px.png"
88+
end if
6989

7090
return userImage
7191
end function

0 commit comments

Comments
 (0)