mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-19 15:47:11 +02:00
Activate account before showing a peer.
This commit is contained in:
parent
99bf61ac8c
commit
e38d39656d
2 changed files with 38 additions and 19 deletions
|
@ -23,6 +23,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "boxes/confirm_box.h"
|
||||
#include "main/main_session.h"
|
||||
#include "main/main_account.h"
|
||||
#include "main/main_domain.h"
|
||||
#include "main/main_app_config.h"
|
||||
#include "mtproto/mtproto_config.h"
|
||||
#include "core/application.h"
|
||||
|
@ -86,26 +87,35 @@ PeerClickHandler::PeerClickHandler(not_null<PeerData*> peer)
|
|||
}
|
||||
|
||||
void PeerClickHandler::onClick(ClickContext context) const {
|
||||
if (context.button == Qt::LeftButton && App::wnd()) {
|
||||
const auto controller = App::wnd()->sessionController();
|
||||
const auto currentPeer = controller->activeChatCurrent().peer();
|
||||
if (_peer && _peer->isChannel() && currentPeer != _peer) {
|
||||
const auto clickedChannel = _peer->asChannel();
|
||||
if (!clickedChannel->isPublic() && !clickedChannel->amIn()
|
||||
&& (!currentPeer->isChannel()
|
||||
|| currentPeer->asChannel()->linkedChat() != clickedChannel)) {
|
||||
Ui::show(Box<InformBox>(_peer->isMegagroup()
|
||||
? tr::lng_group_not_accessible(tr::now)
|
||||
: tr::lng_channel_not_accessible(tr::now)));
|
||||
} else {
|
||||
controller->showPeerHistory(
|
||||
_peer,
|
||||
Window::SectionShow::Way::Forward);
|
||||
}
|
||||
} else {
|
||||
Ui::showPeerProfile(_peer);
|
||||
if (context.button != Qt::LeftButton) {
|
||||
return;
|
||||
}
|
||||
const auto &windows = _peer->session().windows();
|
||||
if (windows.empty()) {
|
||||
Core::App().domain().activate(&_peer->session().account());
|
||||
if (windows.empty()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
const auto window = windows.front();
|
||||
const auto currentPeer = window->activeChatCurrent().peer();
|
||||
if (_peer && _peer->isChannel() && currentPeer != _peer) {
|
||||
const auto clickedChannel = _peer->asChannel();
|
||||
if (!clickedChannel->isPublic()
|
||||
&& !clickedChannel->amIn()
|
||||
&& (!currentPeer->isChannel()
|
||||
|| currentPeer->asChannel()->linkedChat() != clickedChannel)) {
|
||||
Ui::show(Box<InformBox>(_peer->isMegagroup()
|
||||
? tr::lng_group_not_accessible(tr::now)
|
||||
: tr::lng_channel_not_accessible(tr::now)));
|
||||
} else {
|
||||
window->showPeerHistory(
|
||||
_peer,
|
||||
Window::SectionShow::Way::Forward);
|
||||
}
|
||||
} else {
|
||||
Ui::showPeerProfile(_peer);
|
||||
}
|
||||
}
|
||||
|
||||
PeerData::PeerData(not_null<Data::Session*> owner, PeerId id)
|
||||
|
|
|
@ -9,6 +9,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
|
||||
#include <rpl/combine.h>
|
||||
#include "main/main_session.h"
|
||||
#include "main/main_domain.h"
|
||||
#include "core/application.h"
|
||||
#include "apiwrap.h"
|
||||
#include "storage/storage_facade.h"
|
||||
#include "storage/storage_shared_media.h"
|
||||
|
@ -47,7 +49,14 @@ void SharedMediaShowOverview(
|
|||
Storage::SharedMediaType type,
|
||||
not_null<History*> history) {
|
||||
if (SharedMediaOverviewType(type)) {
|
||||
App::wnd()->sessionController()->showSection(Info::Memento(
|
||||
const auto &windows = history->session().windows();
|
||||
if (windows.empty()) {
|
||||
Core::App().domain().activate(&history->session().account());
|
||||
if (windows.empty()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
windows.front()->showSection(Info::Memento(
|
||||
history->peer,
|
||||
Info::Section(type)));
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue