mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +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 "boxes/confirm_box.h"
|
||||||
#include "main/main_session.h"
|
#include "main/main_session.h"
|
||||||
#include "main/main_account.h"
|
#include "main/main_account.h"
|
||||||
|
#include "main/main_domain.h"
|
||||||
#include "main/main_app_config.h"
|
#include "main/main_app_config.h"
|
||||||
#include "mtproto/mtproto_config.h"
|
#include "mtproto/mtproto_config.h"
|
||||||
#include "core/application.h"
|
#include "core/application.h"
|
||||||
|
@ -86,26 +87,35 @@ PeerClickHandler::PeerClickHandler(not_null<PeerData*> peer)
|
||||||
}
|
}
|
||||||
|
|
||||||
void PeerClickHandler::onClick(ClickContext context) const {
|
void PeerClickHandler::onClick(ClickContext context) const {
|
||||||
if (context.button == Qt::LeftButton && App::wnd()) {
|
if (context.button != Qt::LeftButton) {
|
||||||
const auto controller = App::wnd()->sessionController();
|
return;
|
||||||
const auto currentPeer = controller->activeChatCurrent().peer();
|
}
|
||||||
if (_peer && _peer->isChannel() && currentPeer != _peer) {
|
const auto &windows = _peer->session().windows();
|
||||||
const auto clickedChannel = _peer->asChannel();
|
if (windows.empty()) {
|
||||||
if (!clickedChannel->isPublic() && !clickedChannel->amIn()
|
Core::App().domain().activate(&_peer->session().account());
|
||||||
&& (!currentPeer->isChannel()
|
if (windows.empty()) {
|
||||||
|| currentPeer->asChannel()->linkedChat() != clickedChannel)) {
|
return;
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
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)
|
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 <rpl/combine.h>
|
||||||
#include "main/main_session.h"
|
#include "main/main_session.h"
|
||||||
|
#include "main/main_domain.h"
|
||||||
|
#include "core/application.h"
|
||||||
#include "apiwrap.h"
|
#include "apiwrap.h"
|
||||||
#include "storage/storage_facade.h"
|
#include "storage/storage_facade.h"
|
||||||
#include "storage/storage_shared_media.h"
|
#include "storage/storage_shared_media.h"
|
||||||
|
@ -47,7 +49,14 @@ void SharedMediaShowOverview(
|
||||||
Storage::SharedMediaType type,
|
Storage::SharedMediaType type,
|
||||||
not_null<History*> history) {
|
not_null<History*> history) {
|
||||||
if (SharedMediaOverviewType(type)) {
|
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,
|
history->peer,
|
||||||
Info::Section(type)));
|
Info::Section(type)));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue