Refresh token at start up now works, added a bit of a hack to populate account info by opening the login page first and having it populate the data then load the games page, added Cache, and Settings

This commit is contained in:
2021-11-14 18:54:09 -06:00
parent 4b69b60aab
commit b7ccdb2ad3
12 changed files with 207 additions and 35 deletions

View File

@@ -134,18 +134,20 @@ class W3DHub
if news
news.items[0..9].each do |item|
# Cache Image
ext = File.basename(item.image).split(".").last
path = "#{CACHE_PATH}/#{Digest::SHA2.hexdigest(item.image)}.#{ext}"
# ext = File.basename(item.image).split(".").last
# path = "#{CACHE_PATH}/#{Digest::SHA2.hexdigest(item.image)}.#{ext}"
next if File.exist?(path)
# next if File.exist?(path)
response = Excon.get(item.image)
# response = Excon.get(item.image)
if response.status == 200
File.open(path, "wb") do |f|
f.write(response.body)
end
end
# if response.status == 200
# File.open(path, "wb") do |f|
# f.write(response.body)
# end
# end
Cache.fetch(item.image)
end
@@game_news[game.id] = news
@@ -161,8 +163,7 @@ class W3DHub
flow(width: 0.5, height: 128, margin: 4) do
# background 0x88_000000
ext = File.basename(item.image).split(".").last
path = "#{CACHE_PATH}/#{Digest::SHA2.hexdigest(item.image)}.#{ext}"
path = Cache.path(item.image)
if File.exist?(path)
image path, width: 0.4, padding: 4

View File

@@ -41,24 +41,14 @@ class W3DHub
if account
@host.account = account
window.settings[:account][:refresh_token] = account.refresh_token
window.settings.save_settings
ext = File.basename(account.avatar_uri).split(".").last
path = "#{CACHE_PATH}/#{Digest::SHA2.hexdigest(account.avatar_uri)}.#{ext}"
unless File.exist?(path)
response = Excon.get(account.avatar_uri)
if response.status == 200
File.open(path, "wb") do |f|
f.write(response.body)
end
end
end
Cache.fetch(account.avatar_uri)
main_thread_queue << proc { populate_account_info; page(W3DHub::Pages::Games) }
else
# An error occurred, enable account entry
# FIXME: Show an error message
# NOTE: Too many incorrect entries causes lock out (Unknown duration)
main_thread_queue << proc do
@username.enabled = true
@@ -76,6 +66,11 @@ class W3DHub
end
end
end
if @host.account
populate_account_info
page(W3DHub::Pages::Games)
end
end
def populate_account_info
@@ -99,6 +94,9 @@ class W3DHub
end
def depopulate_account_info
window.settings[:account][:refresh_token] = nil
window.settings.save_settings
@host.instance_variable_get(:"@account_container").clear do
stack(width: 0.7, height: 1.0) do
# background 0xff_222222

View File

@@ -14,7 +14,7 @@ class W3DHub
para "<b>App Install Folder</b>", width: 0.249
stack(width: 0.75, height: 1.0) do
edit_line "C:\\Program Files (x86)\\W3D Hub", width: 1.0
edit_line window.settings[:app_install_dir], width: 1.0
inscription "The folder into which new games and apps will be installed by the launcher"
end
end
@@ -23,7 +23,7 @@ class W3DHub
para "<b>Package Cache Folder</b>", width: 0.249
stack(width: 0.75, height: 1.0) do
edit_line "C:\\Program Data\\W3D Hub\\Launcher\\package-cache", width: 1.0
edit_line window.settings[:package_cache_dir], width: 1.0
inscription "A folder which will be used to cache downloaded packages used to install games and apps"
end
end
@@ -33,7 +33,9 @@ class W3DHub
check_box "Enable Automatic Error Reporting", text_size: 16
inscription "If this is enabled the launcher will automatically report errors to the development team, along with basic information about your machine, such as operating system.", width: 1.0
button "Save", margin_top: 32
button "Save", margin_top: 32 do
window.settings.save_settings
end
end
end
end