Grow history stack following joinchat links.

This commit is contained in:
John Preston 2017-11-08 14:45:09 +04:00
parent 1871425b2d
commit 7f8cdf85d5
1 changed files with 30 additions and 12 deletions

View File

@ -4377,7 +4377,7 @@ void MainWidget::inviteCheckDone(QString hash, const MTPChatInvite &invite) {
case mtpc_chatInvite: { case mtpc_chatInvite: {
auto &d = invite.c_chatInvite(); auto &d = invite.c_chatInvite();
QVector<UserData*> participants; auto participants = QVector<UserData*>();
if (d.has_participants()) { if (d.has_participants()) {
auto &v = d.vparticipants.v; auto &v = d.vparticipants.v;
participants.reserve(v.size()); participants.reserve(v.size());
@ -4388,15 +4388,21 @@ void MainWidget::inviteCheckDone(QString hash, const MTPChatInvite &invite) {
} }
} }
_inviteHash = hash; _inviteHash = hash;
auto isChannel = d.is_channel() && !d.is_megagroup(); auto box = Box<ConfirmInviteBox>(
Ui::show(Box<ConfirmInviteBox>(qs(d.vtitle), isChannel, d.vphoto, d.vparticipants_count.v, participants)); qs(d.vtitle),
d.is_channel() && !d.is_megagroup(),
d.vphoto,
d.vparticipants_count.v,
participants);
Ui::show(std::move(box));
} break; } break;
case mtpc_chatInviteAlready: { case mtpc_chatInviteAlready: {
const auto &d(invite.c_chatInviteAlready()); auto &d = invite.c_chatInviteAlready();
PeerData *chat = App::feedChats(MTP_vector<MTPChat>(1, d.vchat)); if (auto chat = App::feedChat(d.vchat)) {
if (chat) { _controller->showPeerHistory(
Ui::showPeerHistory(chat->id, ShowAtUnreadMsgId); chat,
SectionShow::Way::Forward);
} }
} break; } break;
} }
@ -4413,7 +4419,10 @@ bool MainWidget::inviteCheckFail(const RPCError &error) {
void MainWidget::onInviteImport() { void MainWidget::onInviteImport() {
if (_inviteHash.isEmpty()) return; if (_inviteHash.isEmpty()) return;
MTP::send(MTPmessages_ImportChatInvite(MTP_string(_inviteHash)), rpcDone(&MainWidget::inviteImportDone), rpcFail(&MainWidget::inviteImportFail)); MTP::send(
MTPmessages_ImportChatInvite(MTP_string(_inviteHash)),
rpcDone(&MainWidget::inviteImportDone),
rpcFail(&MainWidget::inviteImportFail));
} }
void MainWidget::inviteImportDone(const MTPUpdates &updates) { void MainWidget::inviteImportDone(const MTPUpdates &updates) {
@ -4427,10 +4436,19 @@ void MainWidget::inviteImportDone(const MTPUpdates &updates) {
default: LOG(("API Error: unexpected update cons %1 (MainWidget::inviteImportDone)").arg(updates.type())); break; default: LOG(("API Error: unexpected update cons %1 (MainWidget::inviteImportDone)").arg(updates.type())); break;
} }
if (v && !v->isEmpty()) { if (v && !v->isEmpty()) {
if (v->front().type() == mtpc_chat) { auto &mtpChat = v->front();
Ui::showPeerHistory(peerFromChat(v->front().c_chat().vid.v), ShowAtTheEndMsgId); auto peerId = [&] {
} else if (v->front().type() == mtpc_channel) { if (mtpChat.type() == mtpc_chat) {
Ui::showPeerHistory(peerFromChannel(v->front().c_channel().vid.v), ShowAtTheEndMsgId); return peerFromChat(mtpChat.c_chat().vid.v);
} else if (mtpChat.type() == mtpc_channel) {
return peerFromChannel(mtpChat.c_channel().vid.v);
}
return PeerId(0);
}();
if (auto peer = App::peerLoaded(peerId)) {
_controller->showPeerHistory(
peer,
SectionShow::Way::Forward);
} }
} }
} }