Fix toast hiding on jump to Saved Messages.

This commit is contained in:
John Preston 2022-08-04 16:35:50 +03:00
parent c8ec183c88
commit 4bdac53be2
3 changed files with 24 additions and 0 deletions

View file

@ -3977,6 +3977,7 @@ void HistoryWidget::showAnimated(
}
_topShadow->setVisible(params.withTopBarShadow ? false : true);
_preserveScrollTop = false;
_stickerToast = nullptr;
_cacheOver = controller()->content()->grabForShowAnimation(params);

View file

@ -42,6 +42,12 @@ StickerToast::StickerToast(
StickerToast::~StickerToast() {
cancelRequest();
_hiding.push_back(_weak);
for (const auto &weak : base::take(_hiding)) {
if (const auto strong = weak.get()) {
delete strong->widget();
}
}
}
void StickerToast::showFor(not_null<DocumentData*> document) {
@ -143,6 +149,12 @@ void StickerToast::showWithTitle(const QString &title) {
_st.padding.setLeft(skip + size + skip);
_st.padding.setRight(st::historyPremiumViewSet.font->width(view)
- st::historyPremiumViewSet.width);
clearHiddenHiding();
if (_weak.get()) {
_hiding.push_back(_weak);
}
_weak = Ui::Toast::Show(_parent, Ui::Toast::Config{
.text = text,
.st = &_st,
@ -226,6 +238,15 @@ void StickerToast::showWithTitle(const QString &title) {
});
}
void StickerToast::clearHiddenHiding() {
_hiding.erase(
ranges::remove(
_hiding,
nullptr,
&base::weak_ptr<Ui::Toast::Instance>::get),
end(_hiding));
}
void StickerToast::setupEmojiPreview(
not_null<Ui::RpWidget*> widget,
int size) {

View file

@ -42,11 +42,13 @@ private:
void setupEmojiPreview(not_null<Ui::RpWidget*> widget, int size);
void setupLottiePreview(not_null<Ui::RpWidget*> widget, int size);
void clearHiddenHiding();
const not_null<Window::SessionController*> _controller;
const not_null<QWidget*> _parent;
style::Toast _st;
base::weak_ptr<Ui::Toast::Instance> _weak;
std::vector<base::weak_ptr<Ui::Toast::Instance>> _hiding;
DocumentData *_for = nullptr;
Fn<void()> _destroy;