mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2026-08-06 20:03:12 +00:00
Added parsing of main profile tab from full peer info.
This commit is contained in:
@@ -2048,6 +2048,17 @@ int PeerData::peerGiftsCount() const {
|
||||
return 0;
|
||||
}
|
||||
|
||||
void PeerData::setMainProfileTab(Data::ProfileTab tab) {
|
||||
if (_mainProfileTab != tab) {
|
||||
_mainProfileTab = tab;
|
||||
session().changes().peerUpdated(this, UpdateFlag::MainProfileTab);
|
||||
}
|
||||
}
|
||||
|
||||
Data::ProfileTab PeerData::mainProfileTab() const {
|
||||
return _mainProfileTab;
|
||||
}
|
||||
|
||||
MTPInputPeer PeerData::input() const {
|
||||
if (const auto user = asUser()) {
|
||||
const auto specific = user->inputUser();
|
||||
@@ -2253,6 +2264,44 @@ std::optional<uint8> ColorIndexFromColor(const MTPPeerColor *color) {
|
||||
});
|
||||
}
|
||||
|
||||
ProfileTab ParseProfileTab(const MTPProfileTab *tab) {
|
||||
if (!tab) {
|
||||
return ProfileTab::None;
|
||||
}
|
||||
return tab->match([](const MTPDprofileTabPosts &) {
|
||||
return ProfileTab::Posts;
|
||||
}, [](const MTPDprofileTabGifts &) {
|
||||
return ProfileTab::Gifts;
|
||||
}, [](const MTPDprofileTabMedia &) {
|
||||
return ProfileTab::Media;
|
||||
}, [](const MTPDprofileTabFiles &) {
|
||||
return ProfileTab::Files;
|
||||
}, [](const MTPDprofileTabMusic &) {
|
||||
return ProfileTab::Music;
|
||||
}, [](const MTPDprofileTabVoice &) {
|
||||
return ProfileTab::Voice;
|
||||
}, [](const MTPDprofileTabLinks &) {
|
||||
return ProfileTab::Links;
|
||||
}, [](const MTPDprofileTabGifs &) {
|
||||
return ProfileTab::Gifs;
|
||||
});
|
||||
}
|
||||
|
||||
MTPProfileTab ProfileTabToMTP(ProfileTab tab) {
|
||||
switch (tab) {
|
||||
case ProfileTab::Posts: return MTP_profileTabPosts();
|
||||
case ProfileTab::Gifts: return MTP_profileTabGifts();
|
||||
case ProfileTab::Media: return MTP_profileTabMedia();
|
||||
case ProfileTab::Files: return MTP_profileTabFiles();
|
||||
case ProfileTab::Music: return MTP_profileTabMusic();
|
||||
case ProfileTab::Voice: return MTP_profileTabVoice();
|
||||
case ProfileTab::Links: return MTP_profileTabLinks();
|
||||
case ProfileTab::Gifs: return MTP_profileTabGifs();
|
||||
case ProfileTab::None: break;
|
||||
}
|
||||
Unexpected("Tab in Data::ProfileTabToMTP.");
|
||||
}
|
||||
|
||||
bool IsBotUserCreatesTopics(not_null<PeerData*> peer) {
|
||||
if (const auto user = peer->asUser()) {
|
||||
return user->botInfo && user->botInfo->userCreatesTopics;
|
||||
|
||||
Reference in New Issue
Block a user