showPeerHistory moved to Ui namespace

This commit is contained in:
John Preston 2015-12-13 14:36:08 +03:00
parent 6ec61d4ad6
commit f6fec9a619
15 changed files with 75 additions and 71 deletions

View File

@ -229,7 +229,7 @@ void ContactsInner::onAddBot() {
App::main()->addParticipants(_addToPeer, QVector<UserData*>(1, _bot)); App::main()->addParticipants(_addToPeer, QVector<UserData*>(1, _bot));
} }
Ui::hideLayer(); Ui::hideLayer();
App::main()->showPeerHistory(_addToPeer->id, ShowAtUnreadMsgId); Ui::showPeerHistory(_addToPeer, ShowAtUnreadMsgId);
} }
void ContactsInner::onAddAdmin() { void ContactsInner::onAddAdmin() {
@ -1558,7 +1558,7 @@ void ContactsBox::resizeEvent(QResizeEvent *e) {
void ContactsBox::closePressed() { void ContactsBox::closePressed() {
if (_inner.channel() && !_inner.hasAlreadyMembersInChannel()) { if (_inner.channel() && !_inner.hasAlreadyMembersInChannel()) {
App::main()->showPeerHistory(_inner.channel()->id, ShowAtTheEndMsgId); Ui::showPeerHistory(_inner.channel(), ShowAtTheEndMsgId);
} }
} }
@ -1591,7 +1591,7 @@ void ContactsBox::onInvite() {
App::main()->addParticipants(_inner.chat() ? (PeerData*)_inner.chat() : _inner.channel(), users); App::main()->addParticipants(_inner.chat() ? (PeerData*)_inner.chat() : _inner.channel(), users);
if (_inner.chat()) { if (_inner.chat()) {
Ui::hideLayer(); Ui::hideLayer();
App::main()->showPeerHistory(_inner.chat()->id, ShowAtTheEndMsgId); Ui::showPeerHistory(_inner.chat(), ShowAtTheEndMsgId);
} else { } else {
onClose(); onClose();
} }
@ -1730,7 +1730,7 @@ void ContactsBox::creationDone(const MTPUpdates &updates) {
if (!_creationPhoto.isNull()) { if (!_creationPhoto.isNull()) {
App::app()->uploadProfilePhoto(_creationPhoto, peer->id); App::app()->uploadProfilePhoto(_creationPhoto, peer->id);
} }
App::main()->showPeerHistory(peer->id, ShowAtUnreadMsgId); Ui::showPeerHistory(peer, ShowAtUnreadMsgId);
} }
} else { } else {
LOG(("API Error: chat not found in updates (ContactsBox::creationDone)")); LOG(("API Error: chat not found in updates (ContactsBox::creationDone)"));

View File

@ -687,7 +687,7 @@ void DialogsInner::onContextDeleteAndLeaveSure() {
if (!_menuActionPeer) return; if (!_menuActionPeer) return;
Ui::hideLayer(); Ui::hideLayer();
App::main()->showDialogs(); Ui::showChatsList();
if (_menuActionPeer->isUser()) { if (_menuActionPeer->isUser()) {
App::main()->deleteConversation(_menuActionPeer); App::main()->deleteConversation(_menuActionPeer);
} else if (_menuActionPeer->isChat()) { } else if (_menuActionPeer->isChat()) {
@ -2553,7 +2553,7 @@ bool DialogsWidget::onCancelSearch() {
} }
if (_searchInPeer && !clearing) { if (_searchInPeer && !clearing) {
if (!cWideMode()) { if (!cWideMode()) {
App::main()->showPeerHistory(_searchInPeer->id, ShowAtUnreadMsgId); Ui::showPeerHistory(_searchInPeer, ShowAtUnreadMsgId);
} }
_searchInPeer = _searchInMigrated = 0; _searchInPeer = _searchInMigrated = 0;
_inner.searchInPeer(0); _inner.searchInPeer(0);
@ -2573,7 +2573,7 @@ void DialogsWidget::onCancelSearchInPeer() {
} }
if (_searchInPeer) { if (_searchInPeer) {
if (!cWideMode() && !App::main()->selectingPeer()) { if (!cWideMode() && !App::main()->selectingPeer()) {
App::main()->showPeerHistory(_searchInPeer->id, ShowAtUnreadMsgId); Ui::showPeerHistory(_searchInPeer, ShowAtUnreadMsgId);
} }
_searchInPeer = _searchInMigrated = 0; _searchInPeer = _searchInMigrated = 0;
_inner.searchInPeer(0); _inner.searchInPeer(0);

View File

@ -96,7 +96,7 @@ namespace Ui {
} }
void showPeerHistory(const PeerId &peer, MsgId msgId, bool back) { void showPeerHistory(const PeerId &peer, MsgId msgId, bool back) {
if (MainWidget *m = App::main()) m->showPeerHistory(peer, msgId, back); if (MainWidget *m = App::main()) m->ui_showPeerHistory(peer, msgId, back);
} }
void showPeerHistoryAsync(const PeerId &peer, MsgId msgId) { void showPeerHistoryAsync(const PeerId &peer, MsgId msgId) {

View File

@ -49,7 +49,19 @@ namespace Ui { // openssl doesn't allow me to use UI :(
void redrawHistoryItem(const HistoryItem *item); void redrawHistoryItem(const HistoryItem *item);
void showPeerHistory(const PeerId &peer, MsgId msgId, bool back = false); void showPeerHistory(const PeerId &peer, MsgId msgId, bool back = false);
inline void showPeerHistory(const PeerData *peer, MsgId msgId, bool back = false) {
showPeerHistory(peer->id, msgId, back);
}
inline void showPeerHistory(const History *history, MsgId msgId, bool back = false) {
showPeerHistory(history->peer->id, msgId, back);
}
inline void showPeerHistoryAtItem(const HistoryItem *item) {
showPeerHistory(item->history()->peer->id, item->id);
}
void showPeerHistoryAsync(const PeerId &peer, MsgId msgId); void showPeerHistoryAsync(const PeerId &peer, MsgId msgId);
inline void showChatsList() {
showPeerHistory(PeerId(0), 0);
}
}; };

View File

@ -3789,7 +3789,7 @@ bool HistoryWidget::messagesFailed(const RPCError &error, mtpRequestId requestId
if (error.type() == qstr("CHANNEL_PRIVATE")) { if (error.type() == qstr("CHANNEL_PRIVATE")) {
PeerData *was = _peer; PeerData *was = _peer;
App::main()->showDialogs(); Ui::showChatsList();
Ui::showLayer(new InformBox(lang((was && was->isMegagroup()) ? lng_group_not_accessible : lng_channel_not_accessible))); Ui::showLayer(new InformBox(lang((was && was->isMegagroup()) ? lng_group_not_accessible : lng_channel_not_accessible)));
return true; return true;
} }
@ -3801,7 +3801,7 @@ bool HistoryWidget::messagesFailed(const RPCError &error, mtpRequestId requestId
_preloadDownRequest = 0; _preloadDownRequest = 0;
} else if (_firstLoadRequest == requestId) { } else if (_firstLoadRequest == requestId) {
_firstLoadRequest = 0; _firstLoadRequest = 0;
App::main()->showDialogs(); Ui::showChatsList();
} else if (_delayedShowAtRequest == requestId) { } else if (_delayedShowAtRequest == requestId) {
_delayedShowAtRequest = 0; _delayedShowAtRequest = 0;
} }
@ -4324,7 +4324,7 @@ void HistoryWidget::onBroadcastChange() {
void HistoryWidget::onShareContact(const PeerId &peer, UserData *contact) { void HistoryWidget::onShareContact(const PeerId &peer, UserData *contact) {
if (!contact || contact->phone.isEmpty()) return; if (!contact || contact->phone.isEmpty()) return;
App::main()->showPeerHistory(peer, ShowAtTheEndMsgId); Ui::showPeerHistory(peer, ShowAtTheEndMsgId);
if (!_history) return; if (!_history) return;
shareContact(peer, contact->phone, contact->firstName, contact->lastName, replyToId(), peerToUser(contact->id)); shareContact(peer, contact->phone, contact->firstName, contact->lastName, replyToId(), peerToUser(contact->id));
@ -4367,7 +4367,7 @@ void HistoryWidget::shareContact(const PeerId &peer, const QString &phone, const
} }
void HistoryWidget::onSendPaths(const PeerId &peer) { void HistoryWidget::onSendPaths(const PeerId &peer) {
App::main()->showPeerHistory(peer, ShowAtTheEndMsgId); Ui::showPeerHistory(peer, ShowAtTheEndMsgId);
if (!_history) return; if (!_history) return;
if (cSendPaths().size() == 1) { if (cSendPaths().size() == 1) {
@ -5062,7 +5062,7 @@ void HistoryWidget::topBarClick() {
if (cWideMode()) { if (cWideMode()) {
if (_history) App::main()->showPeerProfile(_peer); if (_history) App::main()->showPeerProfile(_peer);
} else { } else {
App::main()->showDialogs(); Ui::showChatsList();
} }
} }
@ -5571,10 +5571,10 @@ void HistoryWidget::onReportSpamClear() {
if (_clearPeer->isUser()) { if (_clearPeer->isUser()) {
App::main()->deleteConversation(_clearPeer); App::main()->deleteConversation(_clearPeer);
} else if (_clearPeer->isChat()) { } else if (_clearPeer->isChat()) {
App::main()->showDialogs(); Ui::showChatsList();
MTP::send(MTPmessages_DeleteChatUser(_clearPeer->asChat()->inputChat, App::self()->inputUser), App::main()->rpcDone(&MainWidget::deleteHistoryAfterLeave, _clearPeer), App::main()->rpcFail(&MainWidget::leaveChatFailed, _clearPeer)); MTP::send(MTPmessages_DeleteChatUser(_clearPeer->asChat()->inputChat, App::self()->inputUser), App::main()->rpcDone(&MainWidget::deleteHistoryAfterLeave, _clearPeer), App::main()->rpcFail(&MainWidget::leaveChatFailed, _clearPeer));
} else if (_clearPeer->isChannel()) { } else if (_clearPeer->isChannel()) {
App::main()->showDialogs(); Ui::showChatsList();
if (_clearPeer->migrateFrom()) { if (_clearPeer->migrateFrom()) {
App::main()->deleteConversation(_clearPeer->migrateFrom()); App::main()->deleteConversation(_clearPeer->migrateFrom());
} }
@ -6033,7 +6033,7 @@ void HistoryWidget::mousePressEvent(QMouseEvent *e) {
a_recordOver.restart(); a_recordOver.restart();
_a_record.start(); _a_record.start();
} else if (_inReply) { } else if (_inReply) {
App::main()->showPeerHistory(_peer->id, replyToId()); Ui::showPeerHistory(_peer, replyToId());
} }
} }
@ -6050,7 +6050,7 @@ void HistoryWidget::keyPressEvent(QKeyEvent *e) {
PeerData *after = 0; PeerData *after = 0;
MsgId afterMsgId = 0; MsgId afterMsgId = 0;
App::main()->peerAfter(_peer, msgid, after, afterMsgId); App::main()->peerAfter(_peer, msgid, after, afterMsgId);
if (after) App::main()->showPeerHistory(after->id, afterMsgId); if (after) Ui::showPeerHistory(after, afterMsgId);
} else { } else {
_scroll.keyPressEvent(e); _scroll.keyPressEvent(e);
} }
@ -6059,7 +6059,7 @@ void HistoryWidget::keyPressEvent(QKeyEvent *e) {
PeerData *before = 0; PeerData *before = 0;
MsgId beforeMsgId = 0; MsgId beforeMsgId = 0;
App::main()->peerBefore(_peer, msgid, before, beforeMsgId); App::main()->peerBefore(_peer, msgid, before, beforeMsgId);
if (before) App::main()->showPeerHistory(before->id, beforeMsgId); if (before) Ui::showPeerHistory(before, beforeMsgId);
} else { } else {
_scroll.keyPressEvent(e); _scroll.keyPressEvent(e);
} }
@ -6068,7 +6068,7 @@ void HistoryWidget::keyPressEvent(QKeyEvent *e) {
PeerData *after = 0; PeerData *after = 0;
MsgId afterMsgId = 0; MsgId afterMsgId = 0;
App::main()->peerAfter(_peer, msgid, after, afterMsgId); App::main()->peerAfter(_peer, msgid, after, afterMsgId);
if (after) App::main()->showPeerHistory(after->id, afterMsgId); if (after) Ui::showPeerHistory(after, afterMsgId);
} else if (!(e->modifiers() & (Qt::ShiftModifier | Qt::MetaModifier | Qt::ControlModifier))) { } else if (!(e->modifiers() & (Qt::ShiftModifier | Qt::MetaModifier | Qt::ControlModifier))) {
_scroll.keyPressEvent(e); _scroll.keyPressEvent(e);
} }
@ -6077,7 +6077,7 @@ void HistoryWidget::keyPressEvent(QKeyEvent *e) {
PeerData *before = 0; PeerData *before = 0;
MsgId beforeMsgId = 0; MsgId beforeMsgId = 0;
App::main()->peerBefore(_peer, msgid, before, beforeMsgId); App::main()->peerBefore(_peer, msgid, before, beforeMsgId);
if (before) App::main()->showPeerHistory(before->id, beforeMsgId); if (before) Ui::showPeerHistory(before, beforeMsgId);
} else if (!(e->modifiers() & (Qt::ShiftModifier | Qt::MetaModifier | Qt::ControlModifier))) { } else if (!(e->modifiers() & (Qt::ShiftModifier | Qt::MetaModifier | Qt::ControlModifier))) {
_scroll.keyPressEvent(e); _scroll.keyPressEvent(e);
} }
@ -6089,7 +6089,7 @@ void HistoryWidget::keyPressEvent(QKeyEvent *e) {
} else { } else {
App::main()->peerAfter(_peer, msgid, p, m); App::main()->peerAfter(_peer, msgid, p, m);
} }
if (p) App::main()->showPeerHistory(p->id, m); if (p) Ui::showPeerHistory(p, m);
} else if (_history && (e->key() == Qt::Key_Search || e == QKeySequence::Find)) { } else if (_history && (e->key() == Qt::Key_Search || e == QKeySequence::Find)) {
App::main()->searchInPeer(_peer); App::main()->searchInPeer(_peer);
} else { } else {
@ -6380,7 +6380,7 @@ void HistoryWidget::updatePreview() {
} }
void HistoryWidget::onCancel() { void HistoryWidget::onCancel() {
if (App::main()) App::main()->showDialogs(); Ui::showChatsList();
emit cancelled(); emit cancelled();
} }
@ -6421,7 +6421,7 @@ void HistoryWidget::onFullPeerUpdated(PeerData *data) {
void HistoryWidget::peerUpdated(PeerData *data) { void HistoryWidget::peerUpdated(PeerData *data) {
if (data && data == _peer) { if (data && data == _peer) {
if (data->migrateTo()) { if (data->migrateTo()) {
App::main()->showPeerHistory(data->migrateTo()->id, ShowAtUnreadMsgId); Ui::showPeerHistory(data->migrateTo(), ShowAtUnreadMsgId);
QTimer::singleShot(ReloadChannelMembersTimeout, App::api(), SLOT(delayedRequestParticipantsCount())); QTimer::singleShot(ReloadChannelMembersTimeout, App::api(), SLOT(delayedRequestParticipantsCount()));
return; return;
} }

View File

@ -120,7 +120,7 @@ void TopBarWidget::onDeleteContactSure() {
PeerData *p = App::main() ? App::main()->profilePeer() : 0; PeerData *p = App::main() ? App::main()->profilePeer() : 0;
UserData *u = p ? p->asUser() : 0; UserData *u = p ? p->asUser() : 0;
if (u) { if (u) {
App::main()->showDialogs(); Ui::showChatsList();
Ui::hideLayer(); Ui::hideLayer();
MTP::send(MTPcontacts_DeleteContact(u->inputUser), App::main()->rpcDone(&MainWidget::deletedContact, u)); MTP::send(MTPcontacts_DeleteContact(u->inputUser), App::main()->rpcDone(&MainWidget::deletedContact, u));
} }
@ -140,7 +140,7 @@ void TopBarWidget::onDeleteAndExitSure() {
PeerData *p = App::main() ? App::main()->profilePeer() : 0; PeerData *p = App::main() ? App::main()->profilePeer() : 0;
ChatData *c = p ? p->asChat() : 0; ChatData *c = p ? p->asChat() : 0;
if (c) { if (c) {
App::main()->showDialogs(); Ui::showChatsList();
Ui::hideLayer(); Ui::hideLayer();
MTP::send(MTPmessages_DeleteChatUser(c->inputChat, App::self()->inputUser), App::main()->rpcDone(&MainWidget::deleteHistoryAfterLeave, p), App::main()->rpcFail(&MainWidget::leaveChatFailed, p)); MTP::send(MTPmessages_DeleteChatUser(c->inputChat, App::self()->inputUser), App::main()->rpcDone(&MainWidget::deleteHistoryAfterLeave, p), App::main()->rpcFail(&MainWidget::leaveChatFailed, p));
} }
@ -504,7 +504,7 @@ bool MainWidget::onForward(const PeerId &peer, ForwardWhatMessages what) {
} }
} }
updateForwardingTexts(); updateForwardingTexts();
showPeerHistory(peer, ShowAtUnreadMsgId); Ui::showPeerHistory(peer, ShowAtUnreadMsgId);
history.onClearSelected(); history.onClearSelected();
history.updateForwarding(); history.updateForwarding();
return true; return true;
@ -525,7 +525,7 @@ bool MainWidget::onShareUrl(const PeerId &peer, const QString &url, const QStrin
if (opened) { if (opened) {
history.applyDraft(); history.applyDraft();
} else { } else {
showPeerHistory(peer, ShowAtUnreadMsgId); Ui::showPeerHistory(peer, ShowAtUnreadMsgId);
} }
return true; return true;
} }
@ -703,7 +703,7 @@ void MainWidget::onFilesOrForwardDrop(const PeerId &peer, const QMimeData *data)
} else if (data->hasFormat(qsl("application/x-td-forward-pressed"))) { } else if (data->hasFormat(qsl("application/x-td-forward-pressed"))) {
onForward(peer, ForwardPressedMessage); onForward(peer, ForwardPressedMessage);
} else { } else {
showPeerHistory(peer, ShowAtTheEndMsgId); Ui::showPeerHistory(peer, ShowAtTheEndMsgId);
history.onFilesDrop(data); history.onFilesDrop(data);
} }
} }
@ -967,7 +967,7 @@ void MainWidget::removeDialog(History *history) {
void MainWidget::deleteConversation(PeerData *peer, bool deleteHistory) { void MainWidget::deleteConversation(PeerData *peer, bool deleteHistory) {
if (activePeer() == peer) { if (activePeer() == peer) {
showDialogs(); Ui::showChatsList();
} }
if (History *h = App::historyLoaded(peer->id)) { if (History *h = App::historyLoaded(peer->id)) {
removeDialog(h); removeDialog(h);
@ -1003,7 +1003,7 @@ void MainWidget::clearHistory(PeerData *peer) {
h->clear(); h->clear();
h->newLoaded = h->oldLoaded = true; h->newLoaded = h->oldLoaded = true;
} }
showPeerHistory(peer->id, ShowAtUnreadMsgId); Ui::showPeerHistory(peer->id, ShowAtUnreadMsgId);
MTP::send(MTPmessages_DeleteHistory(peer->input, MTP_int(0)), rpcDone(&MainWidget::deleteHistoryPart, peer)); MTP::send(MTPmessages_DeleteHistory(peer->input, MTP_int(0)), rpcDone(&MainWidget::deleteHistoryPart, peer));
} }
@ -1061,7 +1061,7 @@ bool MainWidget::addParticipantsFail(ChannelData *channel, const RPCError &error
void MainWidget::kickParticipant(ChatData *chat, UserData *user) { void MainWidget::kickParticipant(ChatData *chat, UserData *user) {
MTP::send(MTPmessages_DeleteChatUser(chat->inputChat, user->inputUser), rpcDone(&MainWidget::sentUpdatesReceived), rpcFail(&MainWidget::kickParticipantFail, chat)); MTP::send(MTPmessages_DeleteChatUser(chat->inputChat, user->inputUser), rpcDone(&MainWidget::sentUpdatesReceived), rpcFail(&MainWidget::kickParticipantFail, chat));
Ui::hideLayer(); Ui::hideLayer();
showPeerHistory(chat->id, ShowAtTheEndMsgId); Ui::showPeerHistory(chat->id, ShowAtTheEndMsgId);
} }
bool MainWidget::kickParticipantFail(ChatData *chat, const RPCError &error) { bool MainWidget::kickParticipantFail(ChatData *chat, const RPCError &error) {
@ -1352,7 +1352,7 @@ void MainWidget::searchMessages(const QString &query, PeerData *inPeer) {
App::wnd()->hideMediaview(); App::wnd()->hideMediaview();
dialogs.searchMessages(query, inPeer); dialogs.searchMessages(query, inPeer);
if (!cWideMode()) { if (!cWideMode()) {
showDialogs(); Ui::showChatsList();
} else { } else {
dialogs.activate(); dialogs.activate();
} }
@ -2278,7 +2278,7 @@ void MainWidget::choosePeer(PeerId peerId, MsgId showAtMsgId) {
if (selectingPeer()) { if (selectingPeer()) {
offerPeer(peerId); offerPeer(peerId);
} else { } else {
showPeerHistory(peerId, showAtMsgId); Ui::showPeerHistory(peerId, showAtMsgId);
} }
} }
@ -2304,7 +2304,7 @@ void MainWidget::ctrlEnterSubmitUpdated() {
history.ctrlEnterSubmitUpdated(); history.ctrlEnterSubmitUpdated();
} }
void MainWidget::showPeerHistory(quint64 peerId, qint32 showAtMsgId, bool back) { void MainWidget::ui_showPeerHistory(quint64 peerId, qint32 showAtMsgId, bool back) {
if (PeerData *peer = App::peerLoaded(peerId)) { if (PeerData *peer = App::peerLoaded(peerId)) {
if (peer->migrateTo()) { if (peer->migrateTo()) {
peerId = peer->migrateTo()->id; peerId = peer->migrateTo()->id;
@ -2579,7 +2579,7 @@ void MainWidget::showPeerProfile(PeerData *peer, bool back, int32 lastScrollTop)
void MainWidget::showBackFromStack() { void MainWidget::showBackFromStack() {
if (selectingPeer()) return; if (selectingPeer()) return;
if (_stack.isEmpty()) { if (_stack.isEmpty()) {
showDialogs(); Ui::showChatsList();
if (App::wnd()) QTimer::singleShot(0, App::wnd(), SLOT(setInnerFocus())); if (App::wnd()) QTimer::singleShot(0, App::wnd(), SLOT(setInnerFocus()));
return; return;
} }
@ -2598,7 +2598,7 @@ void MainWidget::showBackFromStack() {
} }
} }
StackItemHistory *histItem = static_cast<StackItemHistory*>(item); StackItemHistory *histItem = static_cast<StackItemHistory*>(item);
showPeerHistory(histItem->peer->id, App::main()->activeMsgId(), true); Ui::showPeerHistory(histItem->peer->id, App::main()->activeMsgId(), true);
history.setReplyReturns(histItem->peer->id, histItem->replyReturns); history.setReplyReturns(histItem->peer->id, histItem->replyReturns);
} else if (item->type() == ProfileStackItem) { } else if (item->type() == ProfileStackItem) {
StackItemProfile *profItem = static_cast<StackItemProfile*>(item); StackItemProfile *profItem = static_cast<StackItemProfile*>(item);
@ -2889,10 +2889,6 @@ bool MainWidget::needBackButton() {
return overview || profile || (history.peer() && history.peer()->id); return overview || profile || (history.peer() && history.peer()->id);
} }
void MainWidget::showDialogs() {
showPeerHistory(0, 0);
}
void MainWidget::paintTopBar(QPainter &p, float64 over, int32 decreaseWidth) { void MainWidget::paintTopBar(QPainter &p, float64 over, int32 decreaseWidth) {
if (profile) { if (profile) {
profile->paintTopBar(p, over, decreaseWidth); profile->paintTopBar(p, over, decreaseWidth);
@ -2971,7 +2967,7 @@ void MainWidget::searchInPeer(PeerData *peer) {
dialogs.activate(); dialogs.activate();
} else { } else {
dialogsToUp(); dialogsToUp();
showDialogs(); Ui::showChatsList();
} }
} }
@ -3561,12 +3557,10 @@ void MainWidget::openPeerByName(const QString &username, bool toProfile, const Q
PeerData *peer = App::peerByName(username); PeerData *peer = App::peerByName(username);
if (peer) { if (peer) {
if (toProfile) { if (toProfile && !peer->isChannel()) {
if (peer->isUser() && peer->asUser()->botInfo && !peer->asUser()->botInfo->cantJoinGroups && !startToken.isEmpty()) { if (peer->isUser() && peer->asUser()->botInfo && !peer->asUser()->botInfo->cantJoinGroups && !startToken.isEmpty()) {
peer->asUser()->botInfo->startGroupToken = startToken; peer->asUser()->botInfo->startGroupToken = startToken;
Ui::showLayer(new ContactsBox(peer->asUser())); Ui::showLayer(new ContactsBox(peer->asUser()));
} else if (peer->isChannel()) {
showPeerHistory(peer->id, ShowAtUnreadMsgId);
} else { } else {
showPeerProfile(peer); showPeerProfile(peer);
} }
@ -3578,7 +3572,7 @@ void MainWidget::openPeerByName(const QString &username, bool toProfile, const Q
history.resizeEvent(0); history.resizeEvent(0);
} }
} }
emit showPeerAsync(peer->id, 0); Ui::showPeerHistoryAsync(peer->id, ShowAtUnreadMsgId);
} }
} else { } else {
MTP::send(MTPcontacts_ResolveUsername(MTP_string(username)), rpcDone(&MainWidget::usernameResolveDone, qMakePair(toProfile, startToken)), rpcFail(&MainWidget::usernameResolveFail, username)); MTP::send(MTPcontacts_ResolveUsername(MTP_string(username)), rpcDone(&MainWidget::usernameResolveDone, qMakePair(toProfile, startToken)), rpcFail(&MainWidget::usernameResolveFail, username));
@ -3643,7 +3637,7 @@ void MainWidget::usernameResolveDone(QPair<bool, QString> toProfileStartToken, c
peer->asUser()->botInfo->startGroupToken = toProfileStartToken.second; peer->asUser()->botInfo->startGroupToken = toProfileStartToken.second;
Ui::showLayer(new ContactsBox(peer->asUser())); Ui::showLayer(new ContactsBox(peer->asUser()));
} else if (peer->isChannel()) { } else if (peer->isChannel()) {
showPeerHistory(peer->id, ShowAtUnreadMsgId); Ui::showPeerHistory(peer->id, ShowAtUnreadMsgId);
} else { } else {
showPeerProfile(peer); showPeerProfile(peer);
} }
@ -3655,7 +3649,7 @@ void MainWidget::usernameResolveDone(QPair<bool, QString> toProfileStartToken, c
history.resizeEvent(0); history.resizeEvent(0);
} }
} }
showPeerHistory(peer->id, ShowAtUnreadMsgId); Ui::showPeerHistory(peer->id, ShowAtUnreadMsgId);
} }
} }
@ -3682,7 +3676,7 @@ void MainWidget::inviteCheckDone(QString hash, const MTPChatInvite &invite) {
const MTPDchatInviteAlready &d(invite.c_chatInviteAlready()); const MTPDchatInviteAlready &d(invite.c_chatInviteAlready());
PeerData *chat = App::feedChats(MTP_vector<MTPChat>(1, d.vchat)); PeerData *chat = App::feedChats(MTP_vector<MTPChat>(1, d.vchat));
if (chat) { if (chat) {
showPeerHistory(chat->id, ShowAtUnreadMsgId); Ui::showPeerHistory(chat->id, ShowAtUnreadMsgId);
} }
} break; } break;
} }
@ -3714,9 +3708,9 @@ void MainWidget::inviteImportDone(const MTPUpdates &updates) {
} }
if (v && !v->isEmpty()) { if (v && !v->isEmpty()) {
if (v->front().type() == mtpc_chat) { if (v->front().type() == mtpc_chat) {
App::main()->showPeerHistory(peerFromChat(v->front().c_chat().vid.v), ShowAtTheEndMsgId); Ui::showPeerHistory(peerFromChat(v->front().c_chat().vid.v), ShowAtTheEndMsgId);
} else if (v->front().type() == mtpc_channel) { } else if (v->front().type() == mtpc_channel) {
App::main()->showPeerHistory(peerFromChannel(v->front().c_channel().vid.v), ShowAtTheEndMsgId); Ui::showPeerHistory(peerFromChannel(v->front().c_channel().vid.v), ShowAtTheEndMsgId);
} }
} }
} }

View File

@ -194,7 +194,6 @@ public:
void updateWideMode(); void updateWideMode();
bool needBackButton(); bool needBackButton();
void showDialogs();
void paintTopBar(QPainter &p, float64 over, int32 decreaseWidth); void paintTopBar(QPainter &p, float64 over, int32 decreaseWidth);
TopBarWidget *topBar(); TopBarWidget *topBar();
@ -411,6 +410,7 @@ public:
void ui_showStickerPreview(DocumentData *sticker); void ui_showStickerPreview(DocumentData *sticker);
void ui_hideStickerPreview(); void ui_hideStickerPreview();
void ui_redrawHistoryItem(const HistoryItem *item); void ui_redrawHistoryItem(const HistoryItem *item);
void ui_showPeerHistory(quint64 peer, qint32 msgId, bool back);
void notify_botCommandsChanged(UserData *bot); void notify_botCommandsChanged(UserData *bot);
void notify_userIsBotChanged(UserData *bot); void notify_userIsBotChanged(UserData *bot);
@ -427,7 +427,6 @@ signals:
void peerPhotoChanged(PeerData *peer); void peerPhotoChanged(PeerData *peer);
void dialogRowReplaced(DialogRow *oldRow, DialogRow *newRow); void dialogRowReplaced(DialogRow *oldRow, DialogRow *newRow);
void dialogsUpdated(); void dialogsUpdated();
void showPeerAsync(quint64 peerId, qint32 showAtMsgId);
void stickersUpdated(); void stickersUpdated();
public slots: public slots:
@ -459,7 +458,6 @@ public slots:
void checkIdleFinish(); void checkIdleFinish();
void updateOnlineDisplay(); void updateOnlineDisplay();
void showPeerHistory(quint64 peer, qint32 msgId, bool back = false);
void onTopBarClick(); void onTopBarClick();
void onHistoryShown(History *history, MsgId atMsgId); void onHistoryShown(History *history, MsgId atMsgId);

View File

@ -526,7 +526,7 @@ void MediaView::onToMessage() {
if (HistoryItem *item = _msgid ? App::histItemById(_msgmigrated ? 0 : _channel, _msgid) : 0) { if (HistoryItem *item = _msgid ? App::histItemById(_msgmigrated ? 0 : _channel, _msgid) : 0) {
if (App::wnd()) { if (App::wnd()) {
close(); close();
if (App::main()) App::main()->showPeerHistory(item->history()->peer->id, _msgid); Ui::showPeerHistoryAtItem(item);
} }
} }
} }
@ -1808,7 +1808,7 @@ void MediaView::mouseReleaseEvent(QMouseEvent *e) {
} else { } else {
if (reBotCommand().match(lnk->encoded()).hasMatch() && _history) { if (reBotCommand().match(lnk->encoded()).hasMatch() && _history) {
App::wnd()->hideMediaview(); App::wnd()->hideMediaview();
App::main()->showPeerHistory(_history->peer->id, ShowAtTheEndMsgId); Ui::showPeerHistory(_history, ShowAtTheEndMsgId);
} }
lnk->onClick(e->button()); lnk->onClick(e->button());
} }

View File

@ -2044,7 +2044,7 @@ void OverviewInner::goToMessage() {
HistoryItem *item = App::contextItem(); HistoryItem *item = App::contextItem();
if (!item) return; if (!item) return;
App::main()->showPeerHistory(item->history()->peer->id, item->id); Ui::showPeerHistoryAtItem(item);
} }
void OverviewInner::forwardMessage() { void OverviewInner::forwardMessage() {

View File

@ -237,7 +237,7 @@ void ProfileInner::onInviteToGroup() {
} }
void ProfileInner::onSendMessage() { void ProfileInner::onSendMessage() {
App::main()->showPeerHistory(_peer->id, ShowAtUnreadMsgId); Ui::showPeerHistory(_peer, ShowAtUnreadMsgId);
} }
void ProfileInner::onSearchInPeer() { void ProfileInner::onSearchInPeer() {
@ -329,10 +329,10 @@ void ProfileInner::onDeleteConversationSure() {
if (_peerUser) { if (_peerUser) {
App::main()->deleteConversation(_peer); App::main()->deleteConversation(_peer);
} else if (_peerChat) { } else if (_peerChat) {
App::main()->showDialogs(); Ui::showChatsList();
MTP::send(MTPmessages_DeleteChatUser(_peerChat->inputChat, App::self()->inputUser), App::main()->rpcDone(&MainWidget::deleteHistoryAfterLeave, _peer), App::main()->rpcFail(&MainWidget::leaveChatFailed, _peer)); MTP::send(MTPmessages_DeleteChatUser(_peerChat->inputChat, App::self()->inputUser), App::main()->rpcDone(&MainWidget::deleteHistoryAfterLeave, _peer), App::main()->rpcFail(&MainWidget::leaveChatFailed, _peer));
} else if (_peerChannel) { } else if (_peerChannel) {
App::main()->showDialogs(); Ui::showChatsList();
if (_peerChannel->migrateFrom()) { if (_peerChannel->migrateFrom()) {
App::main()->deleteConversation(_peerChannel->migrateFrom()); App::main()->deleteConversation(_peerChannel->migrateFrom());
} }
@ -350,7 +350,7 @@ void ProfileInner::onDeleteChannel() {
void ProfileInner::onDeleteChannelSure() { void ProfileInner::onDeleteChannelSure() {
if (_peerChannel) { if (_peerChannel) {
Ui::hideLayer(); Ui::hideLayer();
App::main()->showDialogs(); Ui::showChatsList();
if (_peerChannel->migrateFrom()) { if (_peerChannel->migrateFrom()) {
App::main()->deleteConversation(_peerChannel->migrateFrom()); App::main()->deleteConversation(_peerChannel->migrateFrom());
} }
@ -562,7 +562,7 @@ void ProfileInner::onBotSettings() {
for (int32 i = 0, l = _peerUser->botInfo->commands.size(); i != l; ++i) { for (int32 i = 0, l = _peerUser->botInfo->commands.size(); i != l; ++i) {
QString cmd = _peerUser->botInfo->commands.at(i).command; QString cmd = _peerUser->botInfo->commands.at(i).command;
if (!cmd.compare(qsl("settings"), Qt::CaseInsensitive)) { if (!cmd.compare(qsl("settings"), Qt::CaseInsensitive)) {
App::main()->showPeerHistory(_peer->id, ShowAtTheEndMsgId); Ui::showPeerHistory(_peer, ShowAtTheEndMsgId);
App::main()->sendBotCommand('/' + cmd, 0); App::main()->sendBotCommand('/' + cmd, 0);
return; return;
} }
@ -576,7 +576,7 @@ void ProfileInner::onBotHelp() {
for (int32 i = 0, l = _peerUser->botInfo->commands.size(); i != l; ++i) { for (int32 i = 0, l = _peerUser->botInfo->commands.size(); i != l; ++i) {
QString cmd = _peerUser->botInfo->commands.at(i).command; QString cmd = _peerUser->botInfo->commands.at(i).command;
if (!cmd.compare(qsl("help"), Qt::CaseInsensitive)) { if (!cmd.compare(qsl("help"), Qt::CaseInsensitive)) {
App::main()->showPeerHistory(_peer->id, ShowAtTheEndMsgId); Ui::showPeerHistory(_peer, ShowAtTheEndMsgId);
App::main()->sendBotCommand('/' + cmd, 0); App::main()->sendBotCommand('/' + cmd, 0);
return; return;
} }
@ -1085,7 +1085,7 @@ void ProfileInner::mouseReleaseEvent(QMouseEvent *e) {
App::searchByHashtag(lnk->encoded(), _peerChannel); App::searchByHashtag(lnk->encoded(), _peerChannel);
} else { } else {
if (reBotCommand().match(lnk->encoded()).hasMatch()) { if (reBotCommand().match(lnk->encoded()).hasMatch()) {
App::main()->showPeerHistory(_peer->id, ShowAtTheEndMsgId); Ui::showPeerHistory(_peer, ShowAtTheEndMsgId);
} }
lnk->onClick(e->button()); lnk->onClick(e->button());
} }
@ -1250,7 +1250,7 @@ void ProfileInner::migrateDone(const MTPUpdates &updates) {
for (int32 i = 0, l = v->size(); i < l; ++i) { for (int32 i = 0, l = v->size(); i < l; ++i) {
if (v->at(i).type() == mtpc_channel) { if (v->at(i).type() == mtpc_channel) {
peer = App::channel(v->at(i).c_channel().vid.v); peer = App::channel(v->at(i).c_channel().vid.v);
App::main()->showPeerHistory(peer->id, ShowAtUnreadMsgId); Ui::showPeerHistory(peer, ShowAtUnreadMsgId);
QTimer::singleShot(ReloadChannelMembersTimeout, App::api(), SLOT(delayedRequestParticipantsCount())); QTimer::singleShot(ReloadChannelMembersTimeout, App::api(), SLOT(delayedRequestParticipantsCount()));
} }
} }

View File

@ -76,7 +76,7 @@ void MacPrivate::notifyClicked(unsigned long long peer, int msgid) {
tomsg = false; tomsg = false;
} }
} }
App::main()->showPeerHistory(history->peer->id, tomsg ? msgid : ShowAtUnreadMsgId); Ui::showPeerHistory(history, tomsg ? msgid : ShowAtUnreadMsgId);
App::wnd()->notifyClear(history); App::wnd()->notifyClear(history);
} }
} }

View File

@ -2620,7 +2620,7 @@ public:
tomsg = false; tomsg = false;
} }
} }
App::main()->showPeerHistory(history->peer->id, tomsg ? _msgId : ShowAtUnreadMsgId); Ui::showPeerHistory(history, tomsg ? _msgId : ShowAtUnreadMsgId);
App::wnd()->notifyClear(history); App::wnd()->notifyClear(history);
} }
SetForegroundWindow(App::wnd()->psHwnd()); SetForegroundWindow(App::wnd()->psHwnd());

View File

@ -1139,7 +1139,7 @@ void SettingsInner::supportGot(const MTPhelp_Support &support) {
if (support.type() == mtpc_help_support) { if (support.type() == mtpc_help_support) {
const MTPDhelp_support &d(support.c_help_support()); const MTPDhelp_support &d(support.c_help_support());
UserData *u = App::feedUsers(MTP_vector<MTPUser>(1, d.vuser)); UserData *u = App::feedUsers(MTP_vector<MTPUser>(1, d.vuser));
App::main()->showPeerHistory(u->id, ShowAtUnreadMsgId); Ui::showPeerHistory(u, ShowAtUnreadMsgId);
App::wnd()->hideSettings(); App::wnd()->hideSettings();
} }
} }

View File

@ -1110,7 +1110,7 @@ void PeerLink::onClick(Qt::MouseButton button) const {
if (!peer()->asChannel()->isPublic() && !peer()->asChannel()->amIn()) { if (!peer()->asChannel()->isPublic() && !peer()->asChannel()->amIn()) {
Ui::showLayer(new InformBox(lang((peer()->isMegagroup()) ? lng_group_not_accessible : lng_channel_not_accessible))); Ui::showLayer(new InformBox(lang((peer()->isMegagroup()) ? lng_group_not_accessible : lng_channel_not_accessible)));
} else { } else {
App::main()->showPeerHistory(peer()->id, ShowAtUnreadMsgId); Ui::showPeerHistory(peer(), ShowAtUnreadMsgId);
} }
} else { } else {
App::main()->showPeerProfile(peer()); App::main()->showPeerProfile(peer());
@ -1124,13 +1124,13 @@ void MessageLink::onClick(Qt::MouseButton button) const {
if (current && current->history()->peer->id == peer()) { if (current && current->history()->peer->id == peer()) {
App::main()->pushReplyReturn(current); App::main()->pushReplyReturn(current);
} }
App::main()->showPeerHistory(peer(), msgid()); Ui::showPeerHistory(peer(), msgid());
} }
} }
void CommentsLink::onClick(Qt::MouseButton button) const { void CommentsLink::onClick(Qt::MouseButton button) const {
if (button == Qt::LeftButton && App::main() && _item->history()->isChannel()) { if (button == Qt::LeftButton && App::main() && _item->history()->isChannel()) {
App::main()->showPeerHistory(_item->history()->peer->id, _item->id); Ui::showPeerHistoryAtItem(_item);
} }
} }

View File

@ -296,7 +296,7 @@ void NotifyWindow::mousePressEvent(QMouseEvent *e) {
App::wnd()->notifyClear(); App::wnd()->notifyClear();
} else { } else {
App::wnd()->hideSettings(); App::wnd()->hideSettings();
App::main()->showPeerHistory(peer, (!history->peer->isUser() && item && item->mentionsMe() && item->id > 0) ? item->id : ShowAtUnreadMsgId); Ui::showPeerHistory(peer, (!history->peer->isUser() && item && item->mentionsMe() && item->id > 0) ? item->id : ShowAtUnreadMsgId);
} }
e->ignore(); e->ignore();
} }