Populate native desktop status, fixture and news widgets from the session (by Codex)

This commit is contained in:
Codex committed 2026-10-29 13:58:57 +01:00
1 parent fd5c2b5330
commit dc911f3281
21 files changed
+419 -91

No files matched your search

+8 -9
View File
@@ -217,28 +217,27 @@ std::string App::render_news() {
}
std::string App::render_news_widget(const Json &object) {
const auto s = snap();
const auto data = demo_news_view(
*s.world, s.state, "inbox", "",
ui_preferences_.at("display").value("language", std::string("de")));
const auto data = news_data("inbox", "");
const auto raw_items = engine_mode_ ? engine_news_value_.at("items")
: snap().state.at("news").at("items");
if (!data.value("ok", false))
return "";
const bool compact_preview =
object.value("w", 472) <= 472 && object.value("h", 472) <= 472;
const int limit = compact_preview ? 2 : 3;
std::string out =
btn("open:news",
"<span>Postfach · " + std::to_string(data.at("unread").get<int>()) +
btn(engine_mode_ ? "engine-open" : "open:news",
"<span>Postfach · " + std::to_string(data.at(engine_mode_ ? "shown_unread" : "unread").get<int>()) +
" ungelesen</span><span class=\"news-widget-arrow\">" +
glyph("arrow-diagonal", 26) + "</span>",
"news-widget-heading",
"id=\"desktop-news-open\" data-interactive=\"true\" "
"id=\"desktop-news-open\" data-id=\"news\" data-interactive=\"true\" "
"aria-label=\"Nachrichten öffnen\"");
out += "<div class=\"news-widget-feed\">";
int count = 0;
// Gold's widget uses source order, independently of the open tablet's folder,
// search and sorted list. Resolve templates through the same read projection.
for (const auto &raw : s.state.at("news").at("items")) {
for (const auto &raw : raw_items) {
if (raw.at("folder") != "inbox")
continue;
const auto &shown = data.at("items");
@@ -248,7 +247,7 @@ std::string App::render_news_widget(const Json &object) {
if (found == shown.end())
continue;
out += "<div class=\"news-widget-row" +
std::string(found->at("read").get<bool>() ? "" : " unread") +
std::string(found->at("read") == false ? " unread" : "") +
"\"><span class=\"news-widget-dot\"></span><div "
"class=\"news-widget-copy\"><span class=\"news-widget-date\">" +
esc(found->at("display_date").get<std::string>()) +