mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-14 21:27:07 +02:00
Don't offer hello-sticker to user you've blocked.
This commit is contained in:
parent
1444009ee2
commit
d01f977960
5 changed files with 38 additions and 17 deletions
|
@ -4275,32 +4275,32 @@ auto HistoryInner::findViewForPinnedTracking(int top) const
|
|||
return { nullptr, 0 };
|
||||
}
|
||||
|
||||
void HistoryInner::refreshAboutView() {
|
||||
void HistoryInner::refreshAboutView(bool force) {
|
||||
const auto refresh = [&] {
|
||||
if (force) {
|
||||
_aboutView = nullptr;
|
||||
}
|
||||
if (!_aboutView) {
|
||||
_aboutView = std::make_unique<HistoryView::AboutView>(
|
||||
_history,
|
||||
_history->delegateMixin()->delegate());
|
||||
}
|
||||
};
|
||||
if (const auto user = _peer->asUser()) {
|
||||
if (const auto info = user->botInfo.get()) {
|
||||
if (!_aboutView) {
|
||||
_aboutView = std::make_unique<HistoryView::AboutView>(
|
||||
_history,
|
||||
_history->delegateMixin()->delegate());
|
||||
}
|
||||
refresh();
|
||||
if (!info->inited) {
|
||||
session().api().requestFullPeer(user);
|
||||
}
|
||||
} else if (user->meRequiresPremiumToWrite()
|
||||
&& !user->session().premium()
|
||||
&& !historyHeight()) {
|
||||
if (!_aboutView) {
|
||||
_aboutView = std::make_unique<HistoryView::AboutView>(
|
||||
_history,
|
||||
_history->delegateMixin()->delegate());
|
||||
}
|
||||
refresh();
|
||||
} else if (!historyHeight()) {
|
||||
if (!user->isFullLoaded()) {
|
||||
session().api().requestFullPeer(user);
|
||||
} else if (!_aboutView) {
|
||||
_aboutView = std::make_unique<HistoryView::AboutView>(
|
||||
_history,
|
||||
_history->delegateMixin()->delegate());
|
||||
} else {
|
||||
refresh();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -201,7 +201,7 @@ public:
|
|||
[[nodiscard]] std::pair<Element*, int> findViewForPinnedTracking(
|
||||
int top) const;
|
||||
|
||||
void refreshAboutView();
|
||||
void refreshAboutView(bool force = false);
|
||||
void notifyMigrateUpdated();
|
||||
|
||||
// Ui::AbstractTooltipShower interface.
|
||||
|
|
|
@ -8017,13 +8017,18 @@ void HistoryWidget::handlePeerUpdate() {
|
|||
}
|
||||
}
|
||||
if (!_showAnimation) {
|
||||
if (_unblock->isHidden() == isBlocked()
|
||||
const auto blockChanged = (_unblock->isHidden() == isBlocked());
|
||||
if (blockChanged
|
||||
|| (!isBlocked() && _joinChannel->isHidden() == isJoinChannel())) {
|
||||
resize = true;
|
||||
}
|
||||
if (updateCanSendMessage()) {
|
||||
resize = true;
|
||||
}
|
||||
if (blockChanged) {
|
||||
_list->refreshAboutView(true);
|
||||
_list->updateBotInfo();
|
||||
}
|
||||
updateControlsVisibility();
|
||||
if (resize) {
|
||||
updateControlsGeometry();
|
||||
|
|
|
@ -245,6 +245,8 @@ bool AboutView::refresh() {
|
|||
} else if (user->meRequiresPremiumToWrite()
|
||||
&& !user->session().premium()) {
|
||||
setItem(makePremiumRequired(), nullptr);
|
||||
} else if (user->isBlocked()) {
|
||||
setItem(makeBlocked(), nullptr);
|
||||
} else {
|
||||
makeIntro(user);
|
||||
}
|
||||
|
@ -393,4 +395,17 @@ AdminLog::OwnedItem AboutView::makePremiumRequired() {
|
|||
return result;
|
||||
}
|
||||
|
||||
AdminLog::OwnedItem AboutView::makeBlocked() {
|
||||
const auto item = _history->makeMessage({
|
||||
.id = _history->nextNonHistoryEntryId(),
|
||||
.flags = (MessageFlag::FakeAboutView
|
||||
| MessageFlag::FakeHistoryItem
|
||||
| MessageFlag::Local),
|
||||
.from = _history->peer->id,
|
||||
}, PreparedServiceText{
|
||||
{ tr::lng_chat_intro_default_title(tr::now) }
|
||||
});
|
||||
return AdminLog::OwnedItem(_delegate, item);
|
||||
}
|
||||
|
||||
} // namespace HistoryView
|
||||
|
|
|
@ -36,6 +36,7 @@ public:
|
|||
private:
|
||||
[[nodiscard]] AdminLog::OwnedItem makeAboutBot(not_null<BotInfo*> info);
|
||||
[[nodiscard]] AdminLog::OwnedItem makePremiumRequired();
|
||||
[[nodiscard]] AdminLog::OwnedItem makeBlocked();
|
||||
void makeIntro(not_null<UserData*> user);
|
||||
void setItem(AdminLog::OwnedItem item, DocumentData *sticker);
|
||||
void setHelloChosen(not_null<DocumentData*> sticker);
|
||||
|
|
Loading…
Add table
Reference in a new issue