Skip to content

Commit 01906c1

Browse files
23rdjohn-preston
authored andcommitted
Fixed display of archiving toasts on wrong window.
1 parent 9201cf2 commit 01906c1

File tree

3 files changed

+14
-7
lines changed

3 files changed

+14
-7
lines changed

Telegram/SourceFiles/history/view/history_view_contact_status.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -714,8 +714,9 @@ void ContactStatus::setupShareHandler(not_null<UserData*> user) {
714714

715715
void ContactStatus::setupUnarchiveHandler(not_null<PeerData*> peer) {
716716
_inner->unarchiveClicks(
717-
) | rpl::start_with_next([=] {
718-
Window::ToggleHistoryArchived(peer->owner().history(peer), false);
717+
) | rpl::start_with_next([=, show = _controller->uiShow()] {
718+
using namespace Window;
719+
ToggleHistoryArchived(show, peer->owner().history(peer), false);
719720
peer->owner().notifySettings().resetToDefault(peer);
720721
if (const auto settings = peer->settings()) {
721722
const auto flags = PeerSetting::AutoArchived

Telegram/SourceFiles/window/window_peer_menu.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -652,8 +652,8 @@ void Filler::addToggleArchive() {
652652
? tr::lng_archived_remove(tr::now)
653653
: tr::lng_archived_add(tr::now);
654654
};
655-
const auto toggle = [=] {
656-
ToggleHistoryArchived(history, !isArchived());
655+
const auto toggle = [=, show = _controller->uiShow()] {
656+
ToggleHistoryArchived(show, history, !isArchived());
657657
};
658658
const auto archiveAction = _addAction(
659659
label(),
@@ -2406,9 +2406,12 @@ void MenuAddMarkAsReadChatListAction(
24062406
&st::menuIconMarkRead);
24072407
}
24082408

2409-
void ToggleHistoryArchived(not_null<History*> history, bool archived) {
2409+
void ToggleHistoryArchived(
2410+
std::shared_ptr<ChatHelpers::Show> show,
2411+
not_null<History*> history,
2412+
bool archived) {
24102413
const auto callback = [=] {
2411-
Ui::Toast::Show(Ui::Toast::Config{
2414+
show->showToast(Ui::Toast::Config{
24122415
.text = { (archived
24132416
? tr::lng_archived_added(tr::now)
24142417
: tr::lng_archived_removed(tr::now)) },

Telegram/SourceFiles/window/window_peer_menu.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,10 @@ void BlockSenderFromRepliesBox(
116116
not_null<Window::SessionController*> controller,
117117
FullMsgId id);
118118

119-
void ToggleHistoryArchived(not_null<History*> history, bool archived);
119+
void ToggleHistoryArchived(
120+
std::shared_ptr<ChatHelpers::Show> show,
121+
not_null<History*> history,
122+
bool archived);
120123
Fn<void()> ClearHistoryHandler(
121124
not_null<Window::SessionController*> controller,
122125
not_null<PeerData*> peer);

0 commit comments

Comments
 (0)