From ecb470b93894f8d1d4cee314fb67d89713fc7b5c Mon Sep 17 00:00:00 2001 From: ITotalJustice <47043333+ITotalJustice@users.noreply.github.com> Date: Mon, 21 Jul 2025 12:24:28 +0100 Subject: [PATCH] ghdl: display timestamp for each release and asset --- sphaira/include/ui/menus/ghdl.hpp | 3 +++ sphaira/source/ui/menus/ghdl.cpp | 30 +++++++++++++++++---------- sphaira/source/ui/menus/main_menu.cpp | 1 + 3 files changed, 23 insertions(+), 11 deletions(-) diff --git a/sphaira/include/ui/menus/ghdl.hpp b/sphaira/include/ui/menus/ghdl.hpp index daf2a5e..7bec1de 100644 --- a/sphaira/include/ui/menus/ghdl.hpp +++ b/sphaira/include/ui/menus/ghdl.hpp @@ -32,12 +32,15 @@ struct GhApiAsset { std::string content_type{}; u64 size{}; u64 download_count{}; + std::string updated_at{}; std::string browser_download_url{}; }; struct GhApiEntry { std::string tag_name{}; std::string name{}; + std::string published_at{}; + bool prerelease{}; std::vector assets{}; }; diff --git a/sphaira/source/ui/menus/ghdl.cpp b/sphaira/source/ui/menus/ghdl.cpp index 4d08e19..e2b3c66 100644 --- a/sphaira/source/ui/menus/ghdl.cpp +++ b/sphaira/source/ui/menus/ghdl.cpp @@ -72,23 +72,17 @@ void from_json(yyjson_val* json, GhApiAsset& e) { JSON_SET_STR(content_type); JSON_SET_UINT(size); JSON_SET_UINT(download_count); + JSON_SET_STR(updated_at); JSON_SET_STR(browser_download_url); ); } -// void from_json(const fs::FsPath& path, GhApiEntry& e) { -// JSON_INIT_VEC_FILE(path, nullptr, nullptr); -// JSON_OBJ_ITR( -// JSON_SET_STR(tag_name); -// JSON_SET_STR(name); -// JSON_SET_ARR_OBJ(assets); -// ); -// } - void from_json(yyjson_val* json, GhApiEntry& e) { JSON_OBJ_ITR( JSON_SET_STR(tag_name); JSON_SET_STR(name); + JSON_SET_STR(published_at); + JSON_SET_BOOL(prerelease); JSON_SET_ARR_OBJ(assets); ); } @@ -362,7 +356,18 @@ void Menu::DownloadEntries() { PopupList::Items entry_items; for (const auto& e : gh_entries) { - entry_items.emplace_back(e.name); + std::string str; + if (!e.name.empty()) { + str += e.name + " | "; + } else { + str += e.tag_name + " | "; + } + if (e.prerelease) { + str += " (Pre-Release)"; + } + str += " [" + e.published_at.substr(0, 10) + "]"; + + entry_items.emplace_back(str); } App::Push("Select release to download for "_i18n + GetEntry().repo, entry_items, [this](auto op_index){ @@ -393,7 +398,10 @@ void Menu::DownloadEntries() { } if (!using_name || found) { - asset_items.emplace_back(p.name); + std::string str = p.name + " | "; + str += " [" + p.updated_at.substr(0, 10) + "]"; + + asset_items.emplace_back(str); api_assets.emplace_back(p); } } diff --git a/sphaira/source/ui/menus/main_menu.cpp b/sphaira/source/ui/menus/main_menu.cpp index 1d1f6d0..ebfcece 100644 --- a/sphaira/source/ui/menus/main_menu.cpp +++ b/sphaira/source/ui/menus/main_menu.cpp @@ -28,6 +28,7 @@ #include #include +#include namespace sphaira::ui::menu::main { namespace {