mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2026-08-08 04:34:05 +00:00
Merge tag 'v7.0.4' into dev
This commit is contained in:
@@ -438,11 +438,7 @@ void PeerData::paintUserpic(
|
||||
const auto cloud = userpicCloudImage(view);
|
||||
const auto ratio = style::DevicePixelRatio();
|
||||
if (context.shape == Ui::PeerUserpicShape::Auto) {
|
||||
context.shape = (isForum() && !isBot())
|
||||
? Ui::PeerUserpicShape::Forum
|
||||
: isMonoforum()
|
||||
? Ui::PeerUserpicShape::Monoforum
|
||||
: Ui::PeerUserpicShape::Circle;
|
||||
context.shape = userpicShape();
|
||||
}
|
||||
Ui::ValidateUserpicCache(
|
||||
view,
|
||||
@@ -479,6 +475,9 @@ bool PeerData::useEmptyUserpic(Ui::PeerUserpicView &view) const {
|
||||
}
|
||||
|
||||
InMemoryKey PeerData::userpicUniqueKey(Ui::PeerUserpicView &view) const {
|
||||
if (const auto broadcast = monoforumBroadcast()) {
|
||||
return broadcast->userpicUniqueKey(view);
|
||||
}
|
||||
return useEmptyUserpic(view)
|
||||
? ensureEmptyUserpic()->uniqueKey()
|
||||
: inMemoryKey(_userpic.location());
|
||||
@@ -678,7 +677,7 @@ bool PeerData::canPinMessages() const {
|
||||
Unexpected("Peer type in PeerData::canPinMessages.");
|
||||
}
|
||||
|
||||
bool PeerData::canCreatePolls() const {
|
||||
bool PeerData::canCreatePolls(bool forbidInForums) const {
|
||||
if (const auto user = asUser()) {
|
||||
return user->isSelf()
|
||||
|| (user->isBot()
|
||||
@@ -688,15 +687,16 @@ bool PeerData::canCreatePolls() const {
|
||||
} else if (isMonoforum()) {
|
||||
return false;
|
||||
}
|
||||
return Data::CanSend(this, ChatRestriction::SendPolls);
|
||||
return Data::CanSend(this, ChatRestriction::SendPolls, forbidInForums);
|
||||
}
|
||||
|
||||
bool PeerData::canCreateTodoLists() const {
|
||||
bool PeerData::canCreateTodoLists(bool forbidInForums) const {
|
||||
if (isMonoforum() || isBroadcast()) {
|
||||
return false;
|
||||
}
|
||||
return session().premium()
|
||||
&& (Data::CanSend(this, ChatRestriction::SendPolls) || isUser());
|
||||
&& (Data::CanSend(this, ChatRestriction::SendPolls, forbidInForums)
|
||||
|| isUser());
|
||||
}
|
||||
|
||||
bool PeerData::canCreateTopics() const {
|
||||
@@ -1277,7 +1277,10 @@ not_null<const PeerData*> PeerData::userpicPaintingPeer() const {
|
||||
}
|
||||
|
||||
Ui::PeerUserpicShape PeerData::userpicShape() const {
|
||||
return isForum() && !isBot()
|
||||
const auto channel = asChannel();
|
||||
return (isForum() && !isBot())
|
||||
? Ui::PeerUserpicShape::Forum
|
||||
: (channel && channel->isCommunity())
|
||||
? Ui::PeerUserpicShape::Forum
|
||||
: isMonoforum()
|
||||
? Ui::PeerUserpicShape::Monoforum
|
||||
@@ -1682,6 +1685,23 @@ bool PeerData::useSubsectionTabs() const {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool PeerData::displayAsForum() const {
|
||||
if (!isForum()) {
|
||||
return false;
|
||||
} else if (Data::IsBotCreatesTopics(this)) {
|
||||
const auto forum = asBot()->botInfo->forum();
|
||||
return forum && !forum->topicsList()->empty();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool PeerData::displaySubsectionTabs() const {
|
||||
if (asBot()) {
|
||||
return displayAsForum();
|
||||
}
|
||||
return useSubsectionTabs();
|
||||
}
|
||||
|
||||
bool PeerData::viewForumAsMessages() const {
|
||||
if (const auto channel = asChannel()) {
|
||||
return channel->viewForumAsMessages();
|
||||
@@ -2021,6 +2041,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();
|
||||
@@ -2226,6 +2257,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;
|
||||
@@ -2233,4 +2302,11 @@ bool IsBotUserCreatesTopics(not_null<PeerData*> peer) {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool IsBotCreatesTopics(not_null<const PeerData*> peer) {
|
||||
if (const auto user = peer->asUser()) {
|
||||
return user->botInfo && !user->botInfo->userCreatesTopics;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
} // namespace Data
|
||||
|
||||
Reference in New Issue
Block a user