From 91e6c42fcf5485a8484881fc3033d37436454a6f Mon Sep 17 00:00:00 2001 From: John Preston Date: Wed, 15 Feb 2023 10:14:50 +0400 Subject: [PATCH] Fix channel creation flow. --- .../SourceFiles/boxes/add_contact_box.cpp | 21 ++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/Telegram/SourceFiles/boxes/add_contact_box.cpp b/Telegram/SourceFiles/boxes/add_contact_box.cpp index 697a860da..486570e48 100644 --- a/Telegram/SourceFiles/boxes/add_contact_box.cpp +++ b/Telegram/SourceFiles/boxes/add_contact_box.cpp @@ -140,6 +140,19 @@ void MustBePublicFailed( MustBePublicDestroy(channel); } +[[nodiscard]] Fn)> WrapPeerDoneFromChannelDone( + Fn)> channelDone) { + if (!channelDone) { + return nullptr; + } + return [=](not_null peer) { + if (const auto channel = peer->asChannel()) { + const auto onstack = channelDone; + onstack(channel); + } + }; +} + } // namespace TextWithEntities PeerFloodErrorText( @@ -482,13 +495,7 @@ GroupInfoBox::GroupInfoBox( , _api(&_navigation->session().mtp()) , _type(type) , _initialTitle(title) -, _done([channelDone = std::move(channelDone)](not_null peer) { - if (const auto channel = peer->asChannel()) { - if (const auto onstack = channelDone) { - onstack(channel); - } - } -}) { +, _done(WrapPeerDoneFromChannelDone(std::move(channelDone))) { } GroupInfoBox::GroupInfoBox(