mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Show comments button using 'has_link' flag.
This commit is contained in:
parent
01ab6e6d4d
commit
47170da813
4 changed files with 29 additions and 22 deletions
|
@ -153,7 +153,11 @@ void ChannelData::setLinkedChat(ChannelData *linked) {
|
||||||
}
|
}
|
||||||
|
|
||||||
ChannelData *ChannelData::linkedChat() const {
|
ChannelData *ChannelData::linkedChat() const {
|
||||||
return _linkedChat;
|
return _linkedChat.value_or(nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ChannelData::linkedChatKnown() const {
|
||||||
|
return _linkedChat.has_value();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChannelData::setMembersCount(int newMembersCount) {
|
void ChannelData::setMembersCount(int newMembersCount) {
|
||||||
|
|
|
@ -312,6 +312,7 @@ public:
|
||||||
|
|
||||||
void setLinkedChat(ChannelData *linked);
|
void setLinkedChat(ChannelData *linked);
|
||||||
[[nodiscard]] ChannelData *linkedChat() const;
|
[[nodiscard]] ChannelData *linkedChat() const;
|
||||||
|
[[nodiscard]] bool linkedChatKnown() const;
|
||||||
|
|
||||||
void ptsInit(int32 pts) {
|
void ptsInit(int32 pts) {
|
||||||
_ptsWaiter.init(pts);
|
_ptsWaiter.init(pts);
|
||||||
|
@ -436,7 +437,7 @@ private:
|
||||||
std::vector<Data::UnavailableReason> _unavailableReasons;
|
std::vector<Data::UnavailableReason> _unavailableReasons;
|
||||||
std::unique_ptr<InvitePeek> _invitePeek;
|
std::unique_ptr<InvitePeek> _invitePeek;
|
||||||
QString _inviteLink;
|
QString _inviteLink;
|
||||||
ChannelData *_linkedChat = nullptr;
|
std::optional<ChannelData*> _linkedChat;
|
||||||
|
|
||||||
int _slowmodeSeconds = 0;
|
int _slowmodeSeconds = 0;
|
||||||
TimeId _slowmodeLastMessage = 0;
|
TimeId _slowmodeLastMessage = 0;
|
||||||
|
|
|
@ -745,17 +745,26 @@ int HistoryMessage::viewsCount() const {
|
||||||
return HistoryItem::viewsCount();
|
return HistoryItem::viewsCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool HistoryMessage::checkCommentsLinkedChat(ChannelId id) const {
|
||||||
|
if (!id) {
|
||||||
|
return true;
|
||||||
|
} else if (const auto channel = history()->peer->asChannel()) {
|
||||||
|
if (channel->linkedChatKnown()
|
||||||
|
|| !(channel->flags() & MTPDchannel::Flag::f_has_link)) {
|
||||||
|
const auto linked = channel->linkedChat();
|
||||||
|
if (!linked || linked->bareId() != id) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
int HistoryMessage::repliesCount() const {
|
int HistoryMessage::repliesCount() const {
|
||||||
if (const auto views = Get<HistoryMessageViews>()) {
|
if (const auto views = Get<HistoryMessageViews>()) {
|
||||||
if (views->commentsChannelId) {
|
if (!checkCommentsLinkedChat(views->commentsChannelId)) {
|
||||||
if (const auto channel = history()->peer->asChannel()) {
|
return 0;
|
||||||
const auto linked = channel->linkedChat();
|
|
||||||
if (!linked || linked->bareId() != views->commentsChannelId) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return std::max(views->replies.count, 0);
|
return std::max(views->replies.count, 0);
|
||||||
}
|
}
|
||||||
|
@ -764,17 +773,8 @@ int HistoryMessage::repliesCount() const {
|
||||||
|
|
||||||
bool HistoryMessage::repliesAreComments() const {
|
bool HistoryMessage::repliesAreComments() const {
|
||||||
if (const auto views = Get<HistoryMessageViews>()) {
|
if (const auto views = Get<HistoryMessageViews>()) {
|
||||||
if (!views->commentsChannelId) {
|
return (views->commentsChannelId != 0)
|
||||||
return false;
|
&& checkCommentsLinkedChat(views->commentsChannelId);
|
||||||
} else if (const auto channel = history()->peer->asChannel()) {
|
|
||||||
const auto linked = channel->linkedChat();
|
|
||||||
if (!linked || linked->bareId() != views->commentsChannelId) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
return HistoryItem::repliesAreComments();
|
return HistoryItem::repliesAreComments();
|
||||||
}
|
}
|
||||||
|
|
|
@ -198,6 +198,8 @@ private:
|
||||||
return _flags & MTPDmessage::Flag::f_legacy;
|
return _flags & MTPDmessage::Flag::f_legacy;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[[nodiscard]] bool checkCommentsLinkedChat(ChannelId id) const;
|
||||||
|
|
||||||
void clearIsolatedEmoji();
|
void clearIsolatedEmoji();
|
||||||
void checkIsolatedEmoji();
|
void checkIsolatedEmoji();
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue