diff --git a/Telegram/SourceFiles/app.cpp b/Telegram/SourceFiles/app.cpp index 6c8c88b435..d549272717 100644 --- a/Telegram/SourceFiles/app.cpp +++ b/Telegram/SourceFiles/app.cpp @@ -464,10 +464,8 @@ namespace App { data->contact = 0; } if (App::main()) { - if (data->contact > 0 && !wasContact) { - App::main()->addNewContact(peerToUser(data->id), false); - } else if (wasContact && data->contact <= 0) { - App::main()->removeContact(data); + if ((data->contact > 0 && !wasContact) || (wasContact && data->contact < 1)) { + Notify::userIsContactChanged(data); } if (emitPeerUpdated) { @@ -1112,17 +1110,13 @@ namespace App { user->contact = -1; break; } - if (user->contact > 0) { - if (!wasContact) { - App::main()->addNewContact(peerToUser(user->id), false); - } - } else { + if (user->contact < 1) { if (user->contact < 0 && !user->phone.isEmpty() && peerToUser(user->id) != MTP::authedId()) { user->contact = 0; } - if (wasContact) { - App::main()->removeContact(user); - } + } + if ((user->contact > 0 && !wasContact) || (wasContact && user->contact < 1)) { + Notify::userIsContactChanged(user); } bool showPhone = !isServiceUser(user->id) && !user->isSelf() && !user->contact; diff --git a/Telegram/SourceFiles/boxes/addcontactbox.cpp b/Telegram/SourceFiles/boxes/addcontactbox.cpp index ccd5f0eec6..3ba4eac434 100644 --- a/Telegram/SourceFiles/boxes/addcontactbox.cpp +++ b/Telegram/SourceFiles/boxes/addcontactbox.cpp @@ -235,7 +235,7 @@ void AddContactBox::onImportDone(const MTPcontacts_ImportedContacts &res) { } } if (uid) { - App::main()->addNewContact(uid); + Notify::userIsContactChanged(App::userLoaded(peerFromUser(uid)), true); Ui::hideLayer(); } else { _save.hide(); diff --git a/Telegram/SourceFiles/dialogswidget.cpp b/Telegram/SourceFiles/dialogswidget.cpp index 098981019c..b84d3e90d3 100644 --- a/Telegram/SourceFiles/dialogswidget.cpp +++ b/Telegram/SourceFiles/dialogswidget.cpp @@ -488,16 +488,6 @@ void DialogsInner::removeDialog(History *history) { refresh(); } -void DialogsInner::removeContact(UserData *user) { - if (sel && sel->history->peer == user) { - sel = 0; - } - contactsNoDialogs.del(user); - contacts.del(user); - - refresh(); -} - void DialogsInner::dlgUpdated(DialogRow *row) { if (_state == DefaultState) { update(0, row->pos * st::dlgHeight, fullWidth(), st::dlgHeight); @@ -1096,9 +1086,11 @@ void DialogsInner::peopleReceived(const QString &query, const QVector & void DialogsInner::contactsReceived(const QVector &contacts) { for (QVector::const_iterator i = contacts.cbegin(), e = contacts.cend(); i != e; ++i) { int32 uid = i->c_contact().vuser_id.v; - addNewContact(uid); if (uid == MTP::authedId() && App::self()) { - App::self()->contact = 1; + if (App::self()->contact < 1) { + App::self()->contact = 1; + Notify::userIsContactChanged(App::self()); + } } } if (!sel && contactsNoDialogs.list.count && false) { @@ -1108,23 +1100,25 @@ void DialogsInner::contactsReceived(const QVector &contacts) { refresh(); } -int32 DialogsInner::addNewContact(int32 uid, bool select) { // -2 - err, -1 - don't scroll, >= 0 - scroll - PeerId peer = peerFromUser(uid); - if (!App::peerLoaded(peer)) return -2; - - History *history = App::history(peer); - contacts.addByName(history); - DialogsList::RowByPeer::const_iterator i = dialogs.list.rowByPeer.constFind(peer); - if (i == dialogs.list.rowByPeer.cend()) { - DialogRow *added = contactsNoDialogs.addByName(history); - if (!added) return -2; - return -1; +void DialogsInner::notify_userIsContactChanged(UserData *user, bool fromThisApp) { + if (user->contact > 0) { + History *history = App::history(user->id); + contacts.addByName(history); + DialogsList::RowByPeer::const_iterator i = dialogs.list.rowByPeer.constFind(user->id); + if (i == dialogs.list.rowByPeer.cend()) { + contactsNoDialogs.addByName(history); + } else if (fromThisApp) { + sel = i.value(); + contactSel = false; + } + } else { + if (sel && sel->history->peer == user) { + sel = 0; + } + contactsNoDialogs.del(user); + contacts.del(user); } - if (select) { - sel = i.value(); - contactSel = false; - } - return i.value()->pos * st::dlgHeight; + refresh(); } void DialogsInner::refresh(bool toTop) { @@ -1884,6 +1878,15 @@ void DialogsWidget::updateNotifySettings(PeerData *peer) { _inner.updateNotifySettings(peer); } +void DialogsWidget::notify_userIsContactChanged(UserData *user, bool fromThisApp) { + if (fromThisApp) { + _filter.setText(QString()); + _filter.updatePlaceholder(); + onFilterUpdate(); + } + _inner.notify_userIsContactChanged(user, fromThisApp); +} + void DialogsWidget::unreadCountsReceived(const QVector &dialogs) { for (QVector::const_iterator i = dialogs.cbegin(), e = dialogs.cend(); i != e; ++i) { switch (i->type()) { @@ -2270,17 +2273,6 @@ bool DialogsWidget::peopleFailed(const RPCError &error, mtpRequestId req) { return true; } -bool DialogsWidget::addNewContact(int32 uid, bool show) { - _filter.setText(QString()); - _filter.updatePlaceholder(); - onFilterUpdate(); - int32 to = _inner.addNewContact(uid, true); - if (to < -1 || !show) return false; - _inner.refresh(); - if (to >= 0) _scroll.scrollToY(to); - return true; -} - void DialogsWidget::dragEnterEvent(QDragEnterEvent *e) { if (App::main()->selectingPeer()) return; @@ -2537,13 +2529,6 @@ void DialogsWidget::removeDialog(History *history) { onFilterUpdate(); } -void DialogsWidget::removeContact(UserData *user) { - _filter.setText(QString()); - _filter.updatePlaceholder(); - onFilterUpdate(); - _inner.removeContact(user); -} - DialogsIndexed &DialogsWidget::contactsList() { return _inner.contactsList(); } diff --git a/Telegram/SourceFiles/dialogswidget.h b/Telegram/SourceFiles/dialogswidget.h index b35f51de9e..eb0f1cfa01 100644 --- a/Telegram/SourceFiles/dialogswidget.h +++ b/Telegram/SourceFiles/dialogswidget.h @@ -48,7 +48,6 @@ public: void activate(); void contactsReceived(const QVector &contacts); - int32 addNewContact(int32 uid, bool sel = false); // -2 - err, -1 - don't scroll, >= 0 - scroll int32 filteredOffset() const; int32 peopleOffset() const; @@ -72,7 +71,6 @@ public: void dlgUpdated(DialogRow *row); void dlgUpdated(History *row, MsgId msgId); void removeDialog(History *history); - void removeContact(UserData *user); void loadPeerPhotos(int32 yFrom); void clearFilter(); @@ -123,6 +121,8 @@ public: void updateNotifySettings(PeerData *peer); + void notify_userIsContactChanged(UserData *user, bool fromThisApp); + ~DialogsInner(); public slots: @@ -220,7 +220,6 @@ public: void contactsReceived(const MTPcontacts_Contacts &contacts); void searchReceived(DialogsSearchRequestType type, const MTPmessages_Messages &result, mtpRequestId req); void peopleReceived(const MTPcontacts_Found &result, mtpRequestId req); - bool addNewContact(int32 uid, bool show = true); void dragEnterEvent(QDragEnterEvent *e); void dragMoveEvent(QDragMoveEvent *e); @@ -251,7 +250,6 @@ public: void scrollToPeer(const PeerId &peer, MsgId msgId); void removeDialog(History *history); - void removeContact(UserData *user); DialogsIndexed &contactsList(); DialogsIndexed &dialogsList(); @@ -264,6 +262,8 @@ public: void updateNotifySettings(PeerData *peer); + void notify_userIsContactChanged(UserData *user, bool fromThisApp); + signals: void cancelled(); diff --git a/Telegram/SourceFiles/facades.cpp b/Telegram/SourceFiles/facades.cpp index 2a6f40c722..621984dd5e 100644 --- a/Telegram/SourceFiles/facades.cpp +++ b/Telegram/SourceFiles/facades.cpp @@ -91,10 +91,20 @@ namespace Ui { return false; } + void redrawHistoryItem(const HistoryItem *item) { + if (MainWidget *m = App::main()) m->ui_redrawHistoryItem(item); + } + void showPeerHistory(const PeerId &peer, MsgId msgId, bool back) { if (MainWidget *m = App::main()) m->showPeerHistory(peer, msgId, back); } + void showPeerHistoryAsync(const PeerId &peer, MsgId msgId) { + if (MainWidget *m = App::main()) { + QMetaObject::invokeMethod(m, SLOT(ui_showPeerHistoryAsync(quint64,qint32)), Qt::QueuedConnection, Q_ARG(quint64, peer), Q_ARG(qint32, msgId)); + } + } + } namespace Notify { @@ -103,6 +113,10 @@ namespace Notify { if (MainWidget *m = App::main()) m->notify_userIsBotChanged(user); } + void userIsContactChanged(UserData *user, bool fromThisApp) { + if (MainWidget *m = App::main()) m->notify_userIsContactChanged(user, fromThisApp); + } + void botCommandsChanged(UserData *user) { if (MainWidget *m = App::main()) m->notify_botCommandsChanged(user); } @@ -111,10 +125,6 @@ namespace Notify { if (MainWidget *m = App::main()) m->notify_migrateUpdated(peer); } - void redrawHistoryItem(const HistoryItem *item) { - if (MainWidget *m = App::main()) m->notify_redrawHistoryItem(item); - } - void historyItemLayoutChanged(const HistoryItem *item) { if (MainWidget *m = App::main()) m->notify_historyItemLayoutChanged(item); } diff --git a/Telegram/SourceFiles/facades.h b/Telegram/SourceFiles/facades.h index 9ba8cb66b1..3ba786d652 100644 --- a/Telegram/SourceFiles/facades.h +++ b/Telegram/SourceFiles/facades.h @@ -37,7 +37,7 @@ namespace App { }; -namespace Ui { // it doesn't allow me to use UI :( +namespace Ui { // openssl doesn't allow me to use UI :( void showStickerPreview(DocumentData *sticker); void hideStickerPreview(); @@ -46,16 +46,19 @@ namespace Ui { // it doesn't allow me to use UI :( void hideLayer(bool fast = false); bool isLayerShown(); + void redrawHistoryItem(const HistoryItem *item); + void showPeerHistory(const PeerId &peer, MsgId msgId, bool back = false); + void showPeerHistoryAsync(const PeerId &peer, MsgId msgId); }; namespace Notify { void userIsBotChanged(UserData *user); + void userIsContactChanged(UserData *user, bool fromThisApp = false); void botCommandsChanged(UserData *user); void migrateUpdated(PeerData *peer); - void redrawHistoryItem(const HistoryItem *item); void historyItemLayoutChanged(const HistoryItem *item); }; diff --git a/Telegram/SourceFiles/gui/animation.cpp b/Telegram/SourceFiles/gui/animation.cpp index 89c28b3a23..e0d7c2308d 100644 --- a/Telegram/SourceFiles/gui/animation.cpp +++ b/Telegram/SourceFiles/gui/animation.cpp @@ -154,7 +154,7 @@ void AnimatedGif::step_frame(float64 ms, bool timer) { frame = f; if (timer) { if (msg) { - Notify::redrawHistoryItem(msg); + Ui::redrawHistoryItem(msg); } else { emit updated(); } diff --git a/Telegram/SourceFiles/history.cpp b/Telegram/SourceFiles/history.cpp index e1fc158f1b..7713a57085 100644 --- a/Telegram/SourceFiles/history.cpp +++ b/Telegram/SourceFiles/history.cpp @@ -2975,7 +2975,7 @@ void ItemAnimations::step_animate(float64 ms, bool timer) { for (Animations::iterator i = _animations.begin(); i != _animations.end();) { const HistoryItem *item = i.key(); if (item->animating()) { - if (timer) Notify::redrawHistoryItem(item); + if (timer) Ui::redrawHistoryItem(item); ++i; } else { i = _animations.erase(i); @@ -3759,7 +3759,7 @@ void HistoryFileMedia::step_thumbOver(const HistoryItem *parent, float64 ms, boo _animation->a_thumbOver.update(dt, anim::linear); } if (timer) { - Notify::redrawHistoryItem(parent); + Ui::redrawHistoryItem(parent); } } @@ -3769,7 +3769,7 @@ void HistoryFileMedia::step_radial(const HistoryItem *parent, uint64 ms, bool ti checkAnimationFinished(); } if (timer) { - Notify::redrawHistoryItem(parent); + Ui::redrawHistoryItem(parent); } } @@ -4906,7 +4906,7 @@ void HistoryContact::draw(Painter &p, const HistoryItem *parent, const QRect &r, QPixmap thumb = _contact->photo->pixRounded(st::msgFileThumbSize, st::msgFileThumbSize); p.drawPixmap(rthumb.topLeft(), thumb); } else { - p.drawPixmap(rthumb.topLeft(), userDefPhoto(_contact ? _contact->colorIndex : (_userId % UserColorsCount))->pixRounded(st::msgFileThumbSize, st::msgFileThumbSize)); + p.drawPixmap(rthumb.topLeft(), userDefPhoto(_contact ? _contact->colorIndex : (qAbs(_userId) % UserColorsCount))->pixRounded(st::msgFileThumbSize, st::msgFileThumbSize)); } if (selected) { App::roundRect(p, rthumb, textstyleCurrent()->selectOverlay, SelectedOverlayCorners); @@ -4923,7 +4923,7 @@ void HistoryContact::draw(Painter &p, const HistoryItem *parent, const QRect &r, statustop = st::msgFileStatusTop; QRect inner(rtlrect(st::msgFilePadding.left(), st::msgFilePadding.top(), st::msgFileSize, st::msgFileSize, width)); - p.drawPixmap(inner.topLeft(), userDefPhoto(0)->pix(st::msgFileSize, st::msgFileSize)); + p.drawPixmap(inner.topLeft(), userDefPhoto(qAbs(parent->id) % UserColorsCount)->pixRounded(st::msgFileSize, st::msgFileSize)); } int32 namewidth = width - nameleft - nameright; @@ -6566,7 +6566,7 @@ void HistoryMessage::setViewsCount(int32 count) { _viewsText = (_views >= 0) ? formatViewsCount(_views) : QString(); _viewsWidth = _viewsText.isEmpty() ? 0 : st::msgDateFont->width(_viewsText); if (was == _viewsWidth) { - Notify::redrawHistoryItem(this); + Ui::redrawHistoryItem(this); } else { if (_text.hasSkipBlock()) { _text.setSkipBlock(HistoryMessage::skipBlockWidth(), HistoryMessage::skipBlockHeight()); @@ -6582,7 +6582,7 @@ void HistoryMessage::setId(MsgId newId) { bool wasPositive = (id > 0), positive = (newId > 0); HistoryItem::setId(newId); if (wasPositive == positive) { - Notify::redrawHistoryItem(this); + Ui::redrawHistoryItem(this); } else { if (_text.hasSkipBlock()) { _text.setSkipBlock(HistoryMessage::skipBlockWidth(), HistoryMessage::skipBlockHeight()); diff --git a/Telegram/SourceFiles/historywidget.cpp b/Telegram/SourceFiles/historywidget.cpp index b6bb34fc0c..1a094fbf6f 100644 --- a/Telegram/SourceFiles/historywidget.cpp +++ b/Telegram/SourceFiles/historywidget.cpp @@ -5451,7 +5451,7 @@ void HistoryWidget::onPhotoProgress(const FullMsgId &newId) { if (!item->fromChannel()) { updateSendAction(item->history(), SendActionUploadPhoto, 0); } -// Notify::redrawHistoryItem(item); +// Ui::redrawHistoryItem(item); } } @@ -5473,7 +5473,7 @@ void HistoryWidget::onDocumentProgress(const FullMsgId &newId) { if (!item->fromChannel()) { updateSendAction(item->history(), SendActionUploadFile, doc ? doc->uploadOffset : 0); } - Notify::redrawHistoryItem(item); + Ui::redrawHistoryItem(item); } } @@ -5484,7 +5484,7 @@ void HistoryWidget::onAudioProgress(const FullMsgId &newId) { if (!item->fromChannel()) { updateSendAction(item->history(), SendActionUploadAudio, audio ? audio->uploadOffset : 0); } - Notify::redrawHistoryItem(item); + Ui::redrawHistoryItem(item); } } @@ -5495,7 +5495,7 @@ void HistoryWidget::onPhotoFailed(const FullMsgId &newId) { if (!item->fromChannel()) { updateSendAction(item->history(), SendActionUploadPhoto, -1); } -// Notify::redrawHistoryItem(item); +// Ui::redrawHistoryItem(item); } } @@ -5506,7 +5506,7 @@ void HistoryWidget::onDocumentFailed(const FullMsgId &newId) { if (!item->fromChannel()) { updateSendAction(item->history(), SendActionUploadFile, -1); } - Notify::redrawHistoryItem(item); + Ui::redrawHistoryItem(item); } } @@ -5517,7 +5517,7 @@ void HistoryWidget::onAudioFailed(const FullMsgId &newId) { if (!item->fromChannel()) { updateSendAction(item->history(), SendActionUploadAudio, -1); } - Notify::redrawHistoryItem(item); + Ui::redrawHistoryItem(item); } } @@ -5604,7 +5604,7 @@ void HistoryWidget::peerMessagesUpdated() { if (_list) peerMessagesUpdated(_peer->id); } -void HistoryWidget::notify_redrawHistoryItem(const HistoryItem *item) { +void HistoryWidget::ui_redrawHistoryItem(const HistoryItem *item) { if (_peer && _list && (item->history() == _history || (_migrated && item->history() == _migrated))) { _list->redrawItem(item); } @@ -6543,7 +6543,7 @@ void HistoryWidget::onAnimActiveStep() { if (getms() - _animActiveStart > st::activeFadeInDuration + st::activeFadeOutDuration) { stopAnimActive(); } else { - Notify::redrawHistoryItem(item); + Ui::redrawHistoryItem(item); } } diff --git a/Telegram/SourceFiles/historywidget.h b/Telegram/SourceFiles/historywidget.h index 9009e9c2dd..35b5b361c0 100644 --- a/Telegram/SourceFiles/historywidget.h +++ b/Telegram/SourceFiles/historywidget.h @@ -430,8 +430,6 @@ public: void peerMessagesUpdated(PeerId peer); void peerMessagesUpdated(); - void notify_redrawHistoryItem(const HistoryItem *item); - void notify_historyItemLayoutChanged(const HistoryItem *item); void newUnreadMsg(History *history, HistoryItem *item); void historyToDown(History *history); void historyWasRead(bool force = true); @@ -559,6 +557,9 @@ public: resizeEvent(0); } + void ui_redrawHistoryItem(const HistoryItem *item); + + void notify_historyItemLayoutChanged(const HistoryItem *item); void notify_botCommandsChanged(UserData *user); void notify_userIsBotChanged(UserData *user); void notify_migrateUpdated(PeerData *peer); diff --git a/Telegram/SourceFiles/mainwidget.cpp b/Telegram/SourceFiles/mainwidget.cpp index b68f1f9665..e626a8623d 100644 --- a/Telegram/SourceFiles/mainwidget.cpp +++ b/Telegram/SourceFiles/mainwidget.cpp @@ -754,18 +754,37 @@ void MainWidget::notify_userIsBotChanged(UserData *bot) { history.notify_userIsBotChanged(bot); } +void MainWidget::notify_userIsContactChanged(UserData *user, bool fromThisApp) { + if (!user) return; + + dialogs.notify_userIsContactChanged(user, fromThisApp); + + const SharedContactItems &items(App::sharedContactItems()); + SharedContactItems::const_iterator i = items.constFind(peerToUser(user->id)); + if (i != items.cend()) { + for (HistoryItemsMap::const_iterator j = i->cbegin(), e = i->cend(); j != e; ++j) { + j.key()->initDimensions(); + Ui::redrawHistoryItem(j.key()); + } + } + + if (user->contact > 0 && fromThisApp) { + Ui::showPeerHistory(user->id, ShowAtTheEndMsgId); + } +} + void MainWidget::notify_migrateUpdated(PeerData *peer) { history.notify_migrateUpdated(peer); } -void MainWidget::notify_redrawHistoryItem(const HistoryItem *item) { +void MainWidget::ui_redrawHistoryItem(const HistoryItem *item) { if (!item) return; - history.notify_redrawHistoryItem(item); + history.ui_redrawHistoryItem(item); if (!item->history()->dialogs.isEmpty() && item->history()->lastMsg == item) { dialogs.dlgUpdated(item->history()->dialogs[0]); } - if (overview) overview->notify_redrawHistoryItem(item); + if (overview) overview->ui_redrawHistoryItem(item); } void MainWidget::notify_historyItemLayoutChanged(const HistoryItem *item) { @@ -988,10 +1007,6 @@ void MainWidget::clearHistory(PeerData *peer) { MTP::send(MTPmessages_DeleteHistory(peer->input, MTP_int(0)), rpcDone(&MainWidget::deleteHistoryPart, peer)); } -void MainWidget::removeContact(UserData *user) { - dialogs.removeContact(user); -} - void MainWidget::addParticipants(PeerData *chatOrChannel, const QVector &users) { if (chatOrChannel->isChat()) { for (QVector::const_iterator i = users.cbegin(), e = users.cend(); i != e; ++i) { @@ -1488,7 +1503,7 @@ void MainWidget::itemResized(HistoryItem *row, bool scrollToIt) { if (overview) { overview->itemResized(row, scrollToIt); } - if (row) Notify::redrawHistoryItem(row); + if (row) Ui::redrawHistoryItem(row); } bool MainWidget::overviewFailed(PeerData *peer, const RPCError &error, mtpRequestId req) { @@ -1638,7 +1653,7 @@ void MainWidget::videoLoadProgress(mtpFileLoader *loader) { VideoItems::const_iterator i = items.constFind(video); if (i != items.cend()) { for (HistoryItemsMap::const_iterator j = i->cbegin(), e = i->cend(); j != e; ++j) { - Notify::redrawHistoryItem(j.key()); + Ui::redrawHistoryItem(j.key()); } } } @@ -1665,6 +1680,10 @@ void MainWidget::onDownloadPathSettings() { Ui::showLayer(box); } +void MainWidget::ui_showPeerHistoryAsync(quint64 peerId, qint32 showAtMsgId) { + Ui::showPeerHistory(peerId, showAtMsgId); +} + void MainWidget::videoLoadFailed(mtpFileLoader *loader, bool started) { loadFailed(loader, started, SLOT(videoLoadRetry())); VideoData *video = App::video(loader->objId()); @@ -1715,7 +1734,7 @@ void MainWidget::audioLoadProgress(mtpFileLoader *loader) { AudioItems::const_iterator i = items.constFind(audio); if (i != items.cend()) { for (HistoryItemsMap::const_iterator j = i->cbegin(), e = i->cend(); j != e; ++j) { - Notify::redrawHistoryItem(j.key()); + Ui::redrawHistoryItem(j.key()); } } } @@ -1750,7 +1769,7 @@ void MainWidget::audioPlayProgress(const AudioMsgId &audioId) { } if (HistoryItem *item = App::histItemById(audioId.msgId)) { - Notify::redrawHistoryItem(item); + Ui::redrawHistoryItem(item); } } @@ -1811,7 +1830,7 @@ void MainWidget::documentPlayProgress(const SongMsgId &songId) { } if (HistoryItem *item = App::histItemById(songId.msgId)) { - Notify::redrawHistoryItem(item); + Ui::redrawHistoryItem(item); } } @@ -1898,7 +1917,7 @@ void MainWidget::documentLoadProgress(mtpFileLoader *loader) { DocumentItems::const_iterator i = items.constFind(document); if (i != items.cend()) { for (HistoryItemsMap::const_iterator j = i->cbegin(), e = i->cend(); j != e; ++j) { - Notify::redrawHistoryItem(j.key()); + Ui::redrawHistoryItem(j.key()); } } App::wnd()->documentUpdated(document); @@ -3941,12 +3960,6 @@ void MainWidget::updateOnlineDisplayIn(int32 msecs) { _onlineUpdater.start(msecs); } -void MainWidget::addNewContact(int32 uid, bool show) { - if (dialogs.addNewContact(uid, show)) { - showPeerHistory(peerFromUser(uid), ShowAtTheEndMsgId); - } -} - bool MainWidget::isActive() const { return !_isIdle && isVisible() && !_a_show.animating(); } @@ -4232,7 +4245,7 @@ void MainWidget::feedUpdate(const MTPUpdate &update) { msgRow->history()->unregTyping(App::self()); } if (!App::historyRegItem(msgRow)) { - Notify::redrawHistoryItem(msgRow); + Ui::redrawHistoryItem(msgRow); } else { History *h = msgRow->history(); bool wasLast = (h->lastMsg == msgRow); @@ -4261,7 +4274,7 @@ void MainWidget::feedUpdate(const MTPUpdate &update) { if (HistoryItem *item = App::histItemById(NoChannel, v.at(i).v)) { if (item->isMediaUnread()) { item->markMediaRead(); - Notify::redrawHistoryItem(item); + Ui::redrawHistoryItem(item); if (item->out() && item->history()->peer->isUser()) { item->history()->peer->asUser()->madeAction(); } diff --git a/Telegram/SourceFiles/mainwidget.h b/Telegram/SourceFiles/mainwidget.h index 8be8fda5c0..8bd4093216 100644 --- a/Telegram/SourceFiles/mainwidget.h +++ b/Telegram/SourceFiles/mainwidget.h @@ -268,8 +268,6 @@ public: void destroyData(); void updateOnlineDisplayIn(int32 msecs); - void addNewContact(int32 uid, bool show = true); - bool isActive() const; bool historyIsActive() const; bool lastWasOnline() const; @@ -301,7 +299,6 @@ public: void deletedContact(UserData *user, const MTPcontacts_Link &result); void deleteConversation(PeerData *peer, bool deleteHistory = true); void clearHistory(PeerData *peer); - void removeContact(UserData *user); void addParticipants(PeerData *chatOrChannel, const QVector &users); bool addParticipantFail(UserData *user, const RPCError &e); @@ -386,12 +383,6 @@ public: void updateStickers(); - void notify_botCommandsChanged(UserData *bot); - void notify_userIsBotChanged(UserData *bot); - void notify_migrateUpdated(PeerData *peer); - void notify_redrawHistoryItem(const HistoryItem *item); - void notify_historyItemLayoutChanged(const HistoryItem *item); - void choosePeer(PeerId peerId, MsgId showAtMsgId); // does offerPeer or showPeerHistory void clearBotStartToken(PeerData *peer); @@ -419,6 +410,13 @@ public: void ui_showStickerPreview(DocumentData *sticker); void ui_hideStickerPreview(); + void ui_redrawHistoryItem(const HistoryItem *item); + + void notify_botCommandsChanged(UserData *bot); + void notify_userIsBotChanged(UserData *bot); + void notify_userIsContactChanged(UserData *user, bool fromThisApp); + void notify_migrateUpdated(PeerData *peer); + void notify_historyItemLayoutChanged(const HistoryItem *item); ~MainWidget(); @@ -492,6 +490,8 @@ public slots: void onDownloadPathSettings(); + void ui_showPeerHistoryAsync(quint64 peerId, qint32 showAtMsgId); + private: void sendReadRequest(PeerData *peer, MsgId upTo); diff --git a/Telegram/SourceFiles/overviewwidget.cpp b/Telegram/SourceFiles/overviewwidget.cpp index a189b99dbd..d3c40cd096 100644 --- a/Telegram/SourceFiles/overviewwidget.cpp +++ b/Telegram/SourceFiles/overviewwidget.cpp @@ -2997,7 +2997,7 @@ void OverviewWidget::changingMsgId(HistoryItem *row, MsgId newId) { } } -void OverviewWidget::notify_redrawHistoryItem(const HistoryItem *msg) { +void OverviewWidget::ui_redrawHistoryItem(const HistoryItem *msg) { if (peer() == msg->history()->peer || migratePeer() == msg->history()->peer) { _inner.redrawItem(msg); } diff --git a/Telegram/SourceFiles/overviewwidget.h b/Telegram/SourceFiles/overviewwidget.h index 91154ef296..8953db130a 100644 --- a/Telegram/SourceFiles/overviewwidget.h +++ b/Telegram/SourceFiles/overviewwidget.h @@ -313,7 +313,6 @@ public: void mediaOverviewUpdated(PeerData *peer, MediaOverviewType type); void changingMsgId(HistoryItem *row, MsgId newId); - void notify_redrawHistoryItem(const HistoryItem *msg); void itemRemoved(HistoryItem *item); void itemResized(HistoryItem *row, bool scrollToIt); @@ -341,6 +340,8 @@ public: resizeEvent(0); } + void ui_redrawHistoryItem(const HistoryItem *msg); + ~OverviewWidget(); public slots: