Don't show motd if not available

This commit is contained in:
fed 2023-03-06 13:22:05 +01:00
parent d0e148bd54
commit 6434b0ac87
4 changed files with 16 additions and 0 deletions

View File

@ -11,6 +11,10 @@ LUI.MenuBuilder.registerPopupType("motd", function()
end) end)
LUI.onmenuopen("main_campaign", function(menu) LUI.onmenuopen("main_campaign", function(menu)
if (not motd.hasmotd()) then
return
end
if (not motd.hasseentoday()) then if (not motd.hasseentoday()) then
motd.sethasseentoday() motd.sethasseentoday()
LUI.FlowManager.RequestPopupMenu(nil, "motd") LUI.FlowManager.RequestPopupMenu(nil, "motd")

View File

@ -233,6 +233,15 @@ namespace motd
}); });
} }
bool has_motd()
{
return marketing.access<bool>([](nlohmann::json& data)
-> nlohmann::json
{
return data.is_object() && data["motd"].is_object();
});
}
class component final : public component_interface class component final : public component_interface
{ {
public: public:

View File

@ -8,4 +8,5 @@ namespace motd
int get_num_featured_tabs(); int get_num_featured_tabs();
nlohmann::json get_motd(); nlohmann::json get_motd();
nlohmann::json get_featured_tab(const int index); nlohmann::json get_featured_tab(const int index);
bool has_motd();
} }

View File

@ -654,6 +654,8 @@ namespace ui_scripting
const auto now = std::chrono::system_clock::to_time_t(std::chrono::system_clock::now()); const auto now = std::chrono::system_clock::to_time_t(std::chrono::system_clock::now());
config::set<uint64_t>("motd_last_seen", static_cast<uint64_t>(now)); config::set<uint64_t>("motd_last_seen", static_cast<uint64_t>(now));
}; };
motd_table["hasmotd"] = motd::has_motd;
} }
void start() void start()