mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-01-20 06:21:00 +00:00
Support bots as top promoted dialog entries.
This commit is contained in:
parent
042ed8f54a
commit
b6e184d0c8
@ -601,7 +601,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
"lng_proxy_sponsor_about" = "This channel is shown by your proxy server.\nTo remove this channel from your chats list,\ndisable the proxy in Telegram Settings.";
|
||||
"lng_proxy_sponsor_warning" = "This proxy may display a sponsored channel in your chat list. This doesn't reveal any of your Telegram traffic.";
|
||||
"lng_badge_psa_default" = "PSA";
|
||||
"lng_about_psa_default" = "This channel provides you with a public service announcement.\nTo remove this channel from your chats list,\nright click it and select 'Hide'.";
|
||||
"lng_about_psa_default" = "This message provides you with a public service announcement. To remove it from your chats list, right click it and select **Hide**.";
|
||||
|
||||
"lng_settings_blocked_users" = "Blocked users";
|
||||
"lng_settings_no_blocked_users" = "None";
|
||||
|
@ -3732,12 +3732,12 @@ void Session::setTopPromoted(
|
||||
history->requestChatListMessage();
|
||||
Notify::peerUpdatedDelayed(
|
||||
_topPromoted,
|
||||
Notify::PeerUpdate::Flag::ChannelPromotedChanged);
|
||||
Notify::PeerUpdate::Flag::TopPromotedChanged);
|
||||
}
|
||||
if (changed && old) {
|
||||
Notify::peerUpdatedDelayed(
|
||||
old,
|
||||
Notify::PeerUpdate::Flag::ChannelPromotedChanged);
|
||||
Notify::PeerUpdate::Flag::TopPromotedChanged);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2585,6 +2585,8 @@ bool History::useTopPromotion() const {
|
||||
return false;
|
||||
} else if (const auto channel = peer->asChannel()) {
|
||||
return !isPinnedDialog(FilterId()) && !channel->amIn();
|
||||
} else if (const auto user = peer->asUser()) {
|
||||
return !isPinnedDialog(FilterId()) && user->isBot();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@ -2615,6 +2617,10 @@ bool History::shouldBeInChatList() const {
|
||||
return chat->amIn()
|
||||
|| !lastMessageKnown()
|
||||
|| (lastMessage() != nullptr);
|
||||
} else if (const auto user = peer->asUser()) {
|
||||
if (user->isBot() && isTopPromoted()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return !lastMessageKnown()
|
||||
|| (lastMessage() != nullptr);
|
||||
|
@ -520,13 +520,13 @@ HistoryWidget::HistoryWidget(
|
||||
| UpdateFlag::MigrationChanged
|
||||
| UpdateFlag::UnavailableReasonChanged
|
||||
| UpdateFlag::PinnedMessageChanged
|
||||
| UpdateFlag::TopPromotedChanged
|
||||
| UpdateFlag::UserIsBlocked
|
||||
| UpdateFlag::AdminsChanged
|
||||
| UpdateFlag::MembersChanged
|
||||
| UpdateFlag::UserOnlineChanged
|
||||
| UpdateFlag::NotificationsEnabled
|
||||
| UpdateFlag::ChannelAmIn
|
||||
| UpdateFlag::ChannelPromotedChanged
|
||||
| UpdateFlag::ChannelLinkedChat
|
||||
| UpdateFlag::ChannelSlowmode
|
||||
| UpdateFlag::ChannelLocalMessages;
|
||||
@ -564,7 +564,7 @@ HistoryWidget::HistoryWidget(
|
||||
this->update();
|
||||
}
|
||||
}
|
||||
if (update.flags & UpdateFlag::ChannelPromotedChanged) {
|
||||
if (update.flags & UpdateFlag::TopPromotedChanged) {
|
||||
refreshAboutTopPromotion();
|
||||
updateHistoryGeometry();
|
||||
updateControlsVisibility();
|
||||
@ -5210,10 +5210,6 @@ void HistoryWidget::updateHistoryGeometry(
|
||||
}
|
||||
if (!editingMessage() && (isBlocked() || isBotStart() || isJoinChannel() || isMuteUnmute())) {
|
||||
newScrollHeight -= _unblock->height();
|
||||
if (_aboutTopPromotion) {
|
||||
_aboutTopPromotion->resizeToWidth(width());
|
||||
newScrollHeight -= _aboutTopPromotion->height();
|
||||
}
|
||||
} else {
|
||||
if (editingMessage() || _canSendMessages) {
|
||||
newScrollHeight -= (_field->height() + 2 * st::historySendPadding);
|
||||
@ -5227,6 +5223,10 @@ void HistoryWidget::updateHistoryGeometry(
|
||||
newScrollHeight -= _kbScroll->height();
|
||||
}
|
||||
}
|
||||
if (_aboutTopPromotion) {
|
||||
_aboutTopPromotion->resizeToWidth(width());
|
||||
newScrollHeight -= _aboutTopPromotion->height();
|
||||
}
|
||||
if (newScrollHeight <= 0) {
|
||||
return;
|
||||
}
|
||||
|
@ -39,36 +39,37 @@ struct PeerUpdate {
|
||||
UnavailableReasonChanged = (1 << 8),
|
||||
UnreadViewChanged = (1 << 9),
|
||||
PinnedMessageChanged = (1 << 10),
|
||||
TopPromotedChanged = (1 << 11),
|
||||
|
||||
// For chats and channels
|
||||
InviteLinkChanged = (1 << 11),
|
||||
MembersChanged = (1 << 12),
|
||||
AdminsChanged = (1 << 13),
|
||||
BannedUsersChanged = (1 << 14),
|
||||
UnreadMentionsChanged = (1 << 15),
|
||||
RightsChanged = (1 << 16),
|
||||
InviteLinkChanged = (1 << 12),
|
||||
MembersChanged = (1 << 13),
|
||||
AdminsChanged = (1 << 14),
|
||||
BannedUsersChanged = (1 << 15),
|
||||
UnreadMentionsChanged = (1 << 16),
|
||||
RightsChanged = (1 << 17),
|
||||
|
||||
// For users
|
||||
UserCanShareContact = (1 << 17),
|
||||
UserIsContact = (1 << 18),
|
||||
UserPhoneChanged = (1 << 19),
|
||||
UserIsBlocked = (1 << 20),
|
||||
BotCommandsChanged = (1 << 21),
|
||||
UserOnlineChanged = (1 << 22),
|
||||
BotCanAddToGroups = (1 << 23),
|
||||
UserCommonChatsChanged = (1 << 24),
|
||||
UserHasCalls = (1 << 25),
|
||||
UserOccupiedChanged = (1 << 26),
|
||||
UserSupportInfoChanged = (1 << 27),
|
||||
UserCanShareContact = (1 << 18),
|
||||
UserIsContact = (1 << 19),
|
||||
UserPhoneChanged = (1 << 20),
|
||||
UserIsBlocked = (1 << 21),
|
||||
BotCommandsChanged = (1 << 22),
|
||||
UserOnlineChanged = (1 << 23),
|
||||
BotCanAddToGroups = (1 << 24),
|
||||
UserCommonChatsChanged = (1 << 25),
|
||||
UserHasCalls = (1 << 26),
|
||||
UserOccupiedChanged = (1 << 27),
|
||||
UserSupportInfoChanged = (1 << 28),
|
||||
|
||||
// For channels
|
||||
ChannelAmIn = (1 << 17),
|
||||
ChannelStickersChanged = (1 << 18),
|
||||
ChannelPromotedChanged = (1 << 19),
|
||||
ChannelLinkedChat = (1 << 20),
|
||||
ChannelLocation = (1 << 21),
|
||||
ChannelSlowmode = (1 << 22),
|
||||
ChannelLocalMessages = (1 << 23),
|
||||
ChannelAmIn = (1 << 18),
|
||||
ChannelStickersChanged = (1 << 19),
|
||||
ChannelPromotedChanged = (1 << 20),
|
||||
ChannelLinkedChat = (1 << 21),
|
||||
ChannelLocation = (1 << 22),
|
||||
ChannelSlowmode = (1 << 23),
|
||||
ChannelLocalMessages = (1 << 24),
|
||||
};
|
||||
using Flags = base::flags<Flag>;
|
||||
friend inline constexpr auto is_flag_type(Flag) { return true; }
|
||||
|
Loading…
Reference in New Issue
Block a user