Fixed display of most of multiline toasts in corresponding window.

This commit is contained in:
23rd 2022-06-15 06:25:18 +03:00
parent eba606e85e
commit 6d4506f8aa
11 changed files with 38 additions and 11 deletions

View file

@ -586,6 +586,7 @@ void ChannelsLimitBox(
}
}
Ui::ShowMultilineToast({
.parentOverride = Ui::BoxShow(box).toastParent(),
.text = { tr::lng_channels_leave_done(tr::now) },
});
box->closeBox();

View file

@ -594,7 +594,7 @@ void SettingsBox(
});
const auto showToast = crl::guard(box, [=](QString text) {
Ui::ShowMultilineToast({
.parentOverride = box->getDelegate()->outerContainer(),
.parentOverride = Ui::BoxShow(box).toastParent(),
.text = { text },
});
});
@ -637,7 +637,7 @@ void SettingsBox(
QGuiApplication::clipboard()->setText(link);
if (weakBox) {
Ui::ShowMultilineToast({
.parentOverride = box->getDelegate()->outerContainer(),
.parentOverride = Ui::BoxShow(box).toastParent(),
.text = { tr::lng_create_channel_link_copied(tr::now) },
});
}

View file

@ -2434,6 +2434,7 @@ bool HistoryInner::showCopyRestriction(HistoryItem *item) {
return false;
}
Ui::ShowMultilineToast({
.parentOverride = Window::Show(_controller).toastParent(),
.text = { _peer->isBroadcast()
? tr::lng_error_nocopy_channel(tr::now)
: tr::lng_error_nocopy_group(tr::now) },

View file

@ -1008,6 +1008,7 @@ void HistoryWidget::initVoiceRecordBar() {
_voiceRecordBar->recordingTipRequests(
) | rpl::start_with_next([=] {
Ui::ShowMultilineToast({
.parentOverride = Window::Show(controller()).toastParent(),
.text = { tr::lng_record_hold_tip(tr::now) },
});
}, lifetime());
@ -1557,6 +1558,7 @@ void HistoryWidget::toggleChooseChatTheme(not_null<PeerData*> peer) {
return;
} else if (_voiceRecordBar->isActive()) {
Ui::ShowMultilineToast({
.parentOverride = Window::Show(controller()).toastParent(),
.text = { tr::lng_chat_theme_cant_voice(tr::now) },
});
return;
@ -2951,6 +2953,7 @@ void HistoryWidget::messagesFailed(const MTP::Error &error, int requestId) {
auto was = _peer;
controller()->showBackFromStack();
Ui::ShowMultilineToast({
.parentOverride = Window::Show(controller()).toastParent(),
.text = { (was && was->isMegagroup())
? tr::lng_group_not_accessible(tr::now)
: tr::lng_channel_not_accessible(tr::now) },
@ -3736,6 +3739,7 @@ void HistoryWidget::send(Api::SendOptions options) {
options.scheduled);
if (!error.isEmpty()) {
Ui::ShowMultilineToast({
.parentOverride = Window::Show(controller()).toastParent(),
.text = { error },
});
return;
@ -4043,6 +4047,7 @@ void HistoryWidget::chooseAttach(
_peer,
ChatRestriction::SendMedia)) {
Ui::ShowMultilineToast({
.parentOverride = Window::Show(controller()).toastParent(),
.text = { *error },
});
return;
@ -4915,6 +4920,7 @@ bool HistoryWidget::showSendingFilesError(
}
Ui::ShowMultilineToast({
.parentOverride = Window::Show(controller()).toastParent(),
.text = { text },
});
return true;
@ -5313,6 +5319,7 @@ int HistoryWidget::countInitialScrollTop() {
if (itemTop < 0) {
setMsgId(0);
Ui::ShowMultilineToast({
.parentOverride = Window::Show(controller()).toastParent(),
.text = { tr::lng_message_not_found(tr::now) },
});
return countInitialScrollTop();
@ -6185,6 +6192,7 @@ bool HistoryWidget::showSlowmodeError() {
return false;
}
Ui::ShowMultilineToast({
.parentOverride = Window::Show(controller()).toastParent(),
.text = { text },
});
return true;

View file

@ -674,10 +674,16 @@ ClickHandlerPtr Element::fromLink() const {
}
if (const auto forwarded = item->Get<HistoryMessageForwarded>()) {
if (forwarded->imported) {
static const auto imported = std::make_shared<LambdaClickHandler>([] {
Ui::ShowMultilineToast({
.text = { tr::lng_forwarded_imported(tr::now) },
});
static const auto imported = std::make_shared<LambdaClickHandler>([](
ClickContext context) {
const auto my = context.other.value<ClickHandlerContext>();
const auto weak = my.sessionWindow;
if (const auto strong = weak.get()) {
Ui::ShowMultilineToast({
.parentOverride = Window::Show(strong).toastParent(),
.text = { tr::lng_forwarded_imported(tr::now) },
});
}
});
return imported;
}

View file

@ -1210,6 +1210,7 @@ bool ListWidget::showCopyRestriction(HistoryItem *item) {
return false;
}
Ui::ShowMultilineToast({
.parentOverride = Window::Show(_controller).toastParent(),
.text = { (type == CopyRestrictionType::Channel)
? tr::lng_error_nocopy_channel(tr::now)
: tr::lng_error_nocopy_group(tr::now) },

View file

@ -652,6 +652,7 @@ void RepliesWidget::chooseAttach() {
_history->peer,
ChatRestriction::SendMedia)) {
Ui::ShowMultilineToast({
.parentOverride = Window::Show(controller()).toastParent(),
.text = { *error },
});
return;
@ -843,6 +844,7 @@ bool RepliesWidget::showSlowmodeError() {
return false;
}
Ui::ShowMultilineToast({
.parentOverride = Window::Show(controller()).toastParent(),
.text = { text },
});
return true;
@ -954,6 +956,7 @@ bool RepliesWidget::showSendingFilesError(
}
Ui::ShowMultilineToast({
.parentOverride = Window::Show(controller()).toastParent(),
.text = { text },
});
return true;
@ -1009,6 +1012,7 @@ void RepliesWidget::send(Api::SendOptions options) {
// message.textWithTags);
//if (!error.isEmpty()) {
// Ui::ShowMultilineToast({
// .parentOverride = Window::Show(controller()).toastParent(),
// .text = { error },
// });
// return;

View file

@ -319,6 +319,7 @@ void ScheduledWidget::chooseAttach() {
_history->peer,
ChatRestriction::SendMedia)) {
Ui::ShowMultilineToast({
.parentOverride = Window::Show(controller()).toastParent(),
.text = { *error },
});
return;
@ -574,6 +575,7 @@ bool ScheduledWidget::showSendingFilesError(
}
Ui::ShowMultilineToast({
.parentOverride = Window::Show(controller()).toastParent(),
.text = { text },
});
return true;
@ -609,6 +611,7 @@ void ScheduledWidget::send(Api::SendOptions options) {
// message.textWithTags);
//if (!error.isEmpty()) {
// Ui::ShowMultilineToast({
// .parentOverride = Window::Show(controller()).toastParent(),
// .text = { error },
// });
// return;

View file

@ -1253,6 +1253,7 @@ void MainWidget::showChooseReportMessages(
SectionShow::Way::Forward,
ShowForChooseMessagesMsgId);
Ui::ShowMultilineToast({
.parentOverride = Window::Show(controller()).toastParent(),
.text = { tr::lng_report_please_select_messages(tr::now) },
});
}

View file

@ -1266,8 +1266,8 @@ QPointer<Ui::BoxContent> ShowSendNowMessagesBox(
TextWithTags());
if (!error.isEmpty()) {
Ui::ShowMultilineToast({
navigation->parentController()->widget()->bodyWidget(),
{ error },
.parentOverride = Window::Show(navigation).toastParent(),
.text = { error },
});
return { nullptr };
}

View file

@ -266,8 +266,9 @@ void SessionNavigation::resolveChannelById(
}
const auto fail = [=] {
Ui::ShowMultilineToast({
.parentOverride = Window::Show(this).toastParent(),
.text = { tr::lng_error_post_link_invalid(tr::now) }
});
});
};
_api.request(base::take(_resolveRequestId)).cancel();
_resolveRequestId = _api.request(MTPchannels_GetChannels(
@ -400,6 +401,7 @@ void SessionNavigation::joinVoiceChatFromLink(
const auto bad = [=] {
Ui::ShowMultilineToast({
.parentOverride = Window::Show(this).toastParent(),
.text = { tr::lng_group_invite_bad_link(tr::now) }
});
};
@ -428,8 +430,7 @@ void SessionNavigation::joinVoiceChatFromLink(
_resolveRequestId = _api.request(
MTPphone_GetGroupCall(call->input(), MTP_int(limit))
).done([=](const MTPphone_GroupCall &result) {
if (const auto now = peer->groupCall()
; now && now->id() == id) {
if (const auto now = peer->groupCall(); now && now->id() == id) {
if (!now->loaded()) {
now->processFullCall(result);
}
@ -1229,6 +1230,7 @@ void SessionController::showPeer(not_null<PeerData*> peer, MsgId msgId) {
|| currentPeer->asChannel()->linkedChat()
!= clickedChannel)) {
Ui::ShowMultilineToast({
.parentOverride = Window::Show(this).toastParent(),
.text = {
.text = peer->isMegagroup()
? tr::lng_group_not_accessible(tr::now)