From 547124c94f8808d6dca407af7b6eb0d29ac12e45 Mon Sep 17 00:00:00 2001 From: ouwou <26526779+ouwou@users.noreply.github.com> Date: Thu, 21 Jan 2021 23:49:42 -0500 Subject: view and delete invites, more tweaking --- dialogs/joinguild.cpp | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) (limited to 'dialogs') diff --git a/dialogs/joinguild.cpp b/dialogs/joinguild.cpp index 6fd21a8..74b467d 100644 --- a/dialogs/joinguild.cpp +++ b/dialogs/joinguild.cpp @@ -56,25 +56,21 @@ void JoinGuildDialog::on_entry_changed() { } void JoinGuildDialog::CheckCode() { - // clang-format off - Abaddon::Get().GetDiscordClient().FetchInviteData( - m_code, - [this](Invite invite) { - m_ok.set_sensitive(true); - if (invite.Members != -1) - m_info.set_text(invite.Guild.Name + " (" + std::to_string(invite.Members) + " members)"); + auto cb = [this](const std::optional &invite) { + if (invite.has_value()) { + m_ok.set_sensitive(true); + if (invite->Guild.has_value()) { + if (invite->MemberCount.has_value()) + m_info.set_text(invite->Guild->Name + " (" + std::to_string(*invite->MemberCount) + " members)"); else - m_info.set_text(invite.Guild.Name); - }, - [this](bool not_found) { + m_info.set_text(invite->Guild->Name); + } + } else { m_ok.set_sensitive(false); - if (not_found) - m_info.set_text("Invalid invite"); - else - m_info.set_text("HTTP error (try again)"); + m_info.set_text("Invalid invite"); } - ); - // clang-format on + }; + Abaddon::Get().GetDiscordClient().FetchInvite(m_code, sigc::track_obj(cb, *this)); } bool JoinGuildDialog::IsCode(std::string str) { -- cgit v1.2.3