Show signed in user's avatar

This commit is contained in:
2026-10-25 22:51:52 -05:00
parent 57287de742
commit 073f5bebf9
2 changed files with 11 additions and 10 deletions

View File

@@ -55,15 +55,7 @@ module W3DHubLauncher
if result.okay?
hash = JSON.parse(result.data)
MemCache[:settings].account = W3DHubLauncher::Worker::Api::Settings::Account.create(
user_id: hash["userid"],
username: hash["username"],
displayname: hash["displayname"],
avatar_uri: "",
access_token: hash["accessToken"],
refresh_token: hash["refreshToken"],
access_token_expiration_time: hash["accessTokenExpiry"]
)
MemCache[:settings].account = W3DHubLauncher::Worker::Api::Settings::Account.new(hash)
Worker::Api.update_settings(MemCache[:settings]) do |settings_result|
if settings_result.okay?

View File

@@ -336,10 +336,11 @@ module W3DHubLauncher
def populate_account_information
account = MemCache[:settings].account
avatar_path = account ? "#{CACHE_PATH}/avatar_#{account&.user_id}#{File.extname(account&.avatar_uri)}" : nil
@account_container.clear do
# self avatar container
stack(width: 80, height: 1.0, background_image: rounded_avatar(safe_get_image("#{ROOT_PATH}/media/default.png")), tag: :account_avatar) do
stack(width: 80, height: 1.0, background_image: rounded_avatar(safe_get_image(avatar_path || "#{ROOT_PATH}/media/default.png")), tag: :account_avatar) do
# self online state container
stack(
width: 20,
@@ -378,6 +379,14 @@ module W3DHubLauncher
flow(fill: true)
end
end
if account && !account.avatar_uri.empty?
img = find_element_by_tag(@account_container, :account_avatar)
remote_image(avatar_path, url: account.avatar_uri, element: img) do |e, path|
e&.background_image = rounded_avatar(safe_get_image(path))
end
end
end
def button_up(id)