ghdl: display timestamp for each release and asset

This commit is contained in:
ITotalJustice
2025-07-21 12:24:28 +01:00
parent a9d3734117
commit ecb470b938
3 changed files with 23 additions and 11 deletions

View File

@@ -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<GhApiAsset> assets{};
};

View File

@@ -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<PopupList>("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);
}
}

View File

@@ -28,6 +28,7 @@
#include <cstring>
#include <yyjson.h>
#include <iomanip>
namespace sphaira::ui::menu::main {
namespace {