mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Fix new window crash for unavailable channels.
This commit is contained in:
parent
e2624416af
commit
d81c40f4c8
6 changed files with 32 additions and 12 deletions
|
@ -263,7 +263,7 @@ Widget::Widget(
|
||||||
const auto showAtMsgId = controller->uniqueChatsInSearchResults()
|
const auto showAtMsgId = controller->uniqueChatsInSearchResults()
|
||||||
? ShowAtUnreadMsgId
|
? ShowAtUnreadMsgId
|
||||||
: row.message.fullId.msg;
|
: row.message.fullId.msg;
|
||||||
if (row.newWindow) {
|
if (row.newWindow && controller->canShowSeparateWindow(peer)) {
|
||||||
const auto active = controller->activeChatCurrent();
|
const auto active = controller->activeChatCurrent();
|
||||||
if (const auto history = active.history()) {
|
if (const auto history = active.history()) {
|
||||||
if (history->peer == peer) {
|
if (history->peer == peer) {
|
||||||
|
|
|
@ -737,8 +737,10 @@ HistoryWidget::HistoryWidget(
|
||||||
if (flags & PeerUpdateFlag::UnavailableReason) {
|
if (flags & PeerUpdateFlag::UnavailableReason) {
|
||||||
const auto unavailable = _peer->computeUnavailableReason();
|
const auto unavailable = _peer->computeUnavailableReason();
|
||||||
if (!unavailable.isEmpty()) {
|
if (!unavailable.isEmpty()) {
|
||||||
controller->showBackFromStack();
|
closeCurrent();
|
||||||
controller->show(Ui::MakeInformBox(unavailable));
|
if (const auto primary = Core::App().primaryWindow()) {
|
||||||
|
primary->show(Ui::MakeInformBox(unavailable));
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2932,7 +2934,7 @@ void HistoryWidget::unreadCountUpdated() {
|
||||||
if (_history->chatListUnreadMark()) {
|
if (_history->chatListUnreadMark()) {
|
||||||
crl::on_main(this, [=, history = _history] {
|
crl::on_main(this, [=, history = _history] {
|
||||||
if (history == _history) {
|
if (history == _history) {
|
||||||
controller()->showBackFromStack();
|
closeCurrent();
|
||||||
_cancelRequests.fire({});
|
_cancelRequests.fire({});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -2942,6 +2944,14 @@ void HistoryWidget::unreadCountUpdated() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void HistoryWidget::closeCurrent() {
|
||||||
|
if (controller()->isPrimary()) {
|
||||||
|
controller()->showBackFromStack();
|
||||||
|
} else {
|
||||||
|
controller()->window().close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void HistoryWidget::messagesFailed(const MTP::Error &error, int requestId) {
|
void HistoryWidget::messagesFailed(const MTP::Error &error, int requestId) {
|
||||||
if (error.type() == qstr("CHANNEL_PRIVATE")
|
if (error.type() == qstr("CHANNEL_PRIVATE")
|
||||||
&& _peer->isChannel()
|
&& _peer->isChannel()
|
||||||
|
@ -2951,13 +2961,15 @@ void HistoryWidget::messagesFailed(const MTP::Error &error, int requestId) {
|
||||||
|| error.type() == qstr("CHANNEL_PUBLIC_GROUP_NA")
|
|| error.type() == qstr("CHANNEL_PUBLIC_GROUP_NA")
|
||||||
|| error.type() == qstr("USER_BANNED_IN_CHANNEL")) {
|
|| error.type() == qstr("USER_BANNED_IN_CHANNEL")) {
|
||||||
auto was = _peer;
|
auto was = _peer;
|
||||||
controller()->showBackFromStack();
|
closeCurrent();
|
||||||
Ui::ShowMultilineToast({
|
if (const auto primary = Core::App().primaryWindow()) {
|
||||||
.parentOverride = Window::Show(controller()).toastParent(),
|
Ui::ShowMultilineToast({
|
||||||
.text = { (was && was->isMegagroup())
|
.parentOverride = Window::Show(primary).toastParent(),
|
||||||
? tr::lng_group_not_accessible(tr::now)
|
.text = { (was && was->isMegagroup())
|
||||||
: tr::lng_channel_not_accessible(tr::now) },
|
? tr::lng_group_not_accessible(tr::now)
|
||||||
});
|
: tr::lng_channel_not_accessible(tr::now) },
|
||||||
|
});
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2972,7 +2984,7 @@ void HistoryWidget::messagesFailed(const MTP::Error &error, int requestId) {
|
||||||
_preloadDownRequest = 0;
|
_preloadDownRequest = 0;
|
||||||
} else if (_firstLoadRequest == requestId) {
|
} else if (_firstLoadRequest == requestId) {
|
||||||
_firstLoadRequest = 0;
|
_firstLoadRequest = 0;
|
||||||
controller()->showBackFromStack();
|
closeCurrent();
|
||||||
} else if (_delayedShowAtRequest == requestId) {
|
} else if (_delayedShowAtRequest == requestId) {
|
||||||
_delayedShowAtRequest = 0;
|
_delayedShowAtRequest = 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -390,6 +390,7 @@ private:
|
||||||
void handleHistoryChange(not_null<const History*> history);
|
void handleHistoryChange(not_null<const History*> history);
|
||||||
void showAboutTopPromotion();
|
void showAboutTopPromotion();
|
||||||
void unreadCountUpdated();
|
void unreadCountUpdated();
|
||||||
|
void closeCurrent();
|
||||||
|
|
||||||
[[nodiscard]] int computeMaxFieldHeight() const;
|
[[nodiscard]] int computeMaxFieldHeight() const;
|
||||||
void toggleMuteUnmute();
|
void toggleMuteUnmute();
|
||||||
|
|
|
@ -1314,6 +1314,7 @@ void MainWidget::ui_showPeerHistory(
|
||||||
}
|
}
|
||||||
const auto unavailable = peer->computeUnavailableReason();
|
const auto unavailable = peer->computeUnavailableReason();
|
||||||
if (!unavailable.isEmpty()) {
|
if (!unavailable.isEmpty()) {
|
||||||
|
Assert(isPrimary());
|
||||||
if (params.activation != anim::activation::background) {
|
if (params.activation != anim::activation::background) {
|
||||||
controller()->show(Ui::MakeInformBox(unavailable));
|
controller()->show(Ui::MakeInformBox(unavailable));
|
||||||
}
|
}
|
||||||
|
|
|
@ -1220,6 +1220,11 @@ void SessionController::closeThirdSection() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool SessionController::canShowSeparateWindow(
|
||||||
|
not_null<PeerData*> peer) const {
|
||||||
|
return peer->computeUnavailableReason().isEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
void SessionController::showPeer(not_null<PeerData*> peer, MsgId msgId) {
|
void SessionController::showPeer(not_null<PeerData*> peer, MsgId msgId) {
|
||||||
const auto currentPeer = activeChatCurrent().peer();
|
const auto currentPeer = activeChatCurrent().peer();
|
||||||
if (peer && peer->isChannel() && currentPeer != peer) {
|
if (peer && peer->isChannel() && currentPeer != peer) {
|
||||||
|
|
|
@ -380,6 +380,7 @@ public:
|
||||||
void resizeForThirdSection();
|
void resizeForThirdSection();
|
||||||
void closeThirdSection();
|
void closeThirdSection();
|
||||||
|
|
||||||
|
[[nodiscard]] bool canShowSeparateWindow(not_null<PeerData*> peer) const;
|
||||||
void showPeer(not_null<PeerData*> peer, MsgId msgId = ShowAtUnreadMsgId);
|
void showPeer(not_null<PeerData*> peer, MsgId msgId = ShowAtUnreadMsgId);
|
||||||
|
|
||||||
void startOrJoinGroupCall(
|
void startOrJoinGroupCall(
|
||||||
|
|
Loading…
Add table
Reference in a new issue