redrawHistoryItem moved to Ui, shared contact updates when is_contact changes

This commit is contained in:
John Preston 2015-12-13 14:17:15 +03:00
parent 2225abec5c
commit 6ec61d4ad6
14 changed files with 126 additions and 119 deletions

View File

@ -464,10 +464,8 @@ namespace App {
data->contact = 0; data->contact = 0;
} }
if (App::main()) { if (App::main()) {
if (data->contact > 0 && !wasContact) { if ((data->contact > 0 && !wasContact) || (wasContact && data->contact < 1)) {
App::main()->addNewContact(peerToUser(data->id), false); Notify::userIsContactChanged(data);
} else if (wasContact && data->contact <= 0) {
App::main()->removeContact(data);
} }
if (emitPeerUpdated) { if (emitPeerUpdated) {
@ -1112,17 +1110,13 @@ namespace App {
user->contact = -1; user->contact = -1;
break; break;
} }
if (user->contact > 0) { if (user->contact < 1) {
if (!wasContact) {
App::main()->addNewContact(peerToUser(user->id), false);
}
} else {
if (user->contact < 0 && !user->phone.isEmpty() && peerToUser(user->id) != MTP::authedId()) { if (user->contact < 0 && !user->phone.isEmpty() && peerToUser(user->id) != MTP::authedId()) {
user->contact = 0; 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; bool showPhone = !isServiceUser(user->id) && !user->isSelf() && !user->contact;

View File

@ -235,7 +235,7 @@ void AddContactBox::onImportDone(const MTPcontacts_ImportedContacts &res) {
} }
} }
if (uid) { if (uid) {
App::main()->addNewContact(uid); Notify::userIsContactChanged(App::userLoaded(peerFromUser(uid)), true);
Ui::hideLayer(); Ui::hideLayer();
} else { } else {
_save.hide(); _save.hide();

View File

@ -488,16 +488,6 @@ void DialogsInner::removeDialog(History *history) {
refresh(); 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) { void DialogsInner::dlgUpdated(DialogRow *row) {
if (_state == DefaultState) { if (_state == DefaultState) {
update(0, row->pos * st::dlgHeight, fullWidth(), st::dlgHeight); update(0, row->pos * st::dlgHeight, fullWidth(), st::dlgHeight);
@ -1096,9 +1086,11 @@ void DialogsInner::peopleReceived(const QString &query, const QVector<MTPPeer> &
void DialogsInner::contactsReceived(const QVector<MTPContact> &contacts) { void DialogsInner::contactsReceived(const QVector<MTPContact> &contacts) {
for (QVector<MTPContact>::const_iterator i = contacts.cbegin(), e = contacts.cend(); i != e; ++i) { for (QVector<MTPContact>::const_iterator i = contacts.cbegin(), e = contacts.cend(); i != e; ++i) {
int32 uid = i->c_contact().vuser_id.v; int32 uid = i->c_contact().vuser_id.v;
addNewContact(uid);
if (uid == MTP::authedId() && App::self()) { 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) { if (!sel && contactsNoDialogs.list.count && false) {
@ -1108,23 +1100,25 @@ void DialogsInner::contactsReceived(const QVector<MTPContact> &contacts) {
refresh(); refresh();
} }
int32 DialogsInner::addNewContact(int32 uid, bool select) { // -2 - err, -1 - don't scroll, >= 0 - scroll void DialogsInner::notify_userIsContactChanged(UserData *user, bool fromThisApp) {
PeerId peer = peerFromUser(uid); if (user->contact > 0) {
if (!App::peerLoaded(peer)) return -2; History *history = App::history(user->id);
contacts.addByName(history);
History *history = App::history(peer); DialogsList::RowByPeer::const_iterator i = dialogs.list.rowByPeer.constFind(user->id);
contacts.addByName(history); if (i == dialogs.list.rowByPeer.cend()) {
DialogsList::RowByPeer::const_iterator i = dialogs.list.rowByPeer.constFind(peer); contactsNoDialogs.addByName(history);
if (i == dialogs.list.rowByPeer.cend()) { } else if (fromThisApp) {
DialogRow *added = contactsNoDialogs.addByName(history); sel = i.value();
if (!added) return -2; contactSel = false;
return -1; }
} else {
if (sel && sel->history->peer == user) {
sel = 0;
}
contactsNoDialogs.del(user);
contacts.del(user);
} }
if (select) { refresh();
sel = i.value();
contactSel = false;
}
return i.value()->pos * st::dlgHeight;
} }
void DialogsInner::refresh(bool toTop) { void DialogsInner::refresh(bool toTop) {
@ -1884,6 +1878,15 @@ void DialogsWidget::updateNotifySettings(PeerData *peer) {
_inner.updateNotifySettings(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<MTPDialog> &dialogs) { void DialogsWidget::unreadCountsReceived(const QVector<MTPDialog> &dialogs) {
for (QVector<MTPDialog>::const_iterator i = dialogs.cbegin(), e = dialogs.cend(); i != e; ++i) { for (QVector<MTPDialog>::const_iterator i = dialogs.cbegin(), e = dialogs.cend(); i != e; ++i) {
switch (i->type()) { switch (i->type()) {
@ -2270,17 +2273,6 @@ bool DialogsWidget::peopleFailed(const RPCError &error, mtpRequestId req) {
return true; 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) { void DialogsWidget::dragEnterEvent(QDragEnterEvent *e) {
if (App::main()->selectingPeer()) return; if (App::main()->selectingPeer()) return;
@ -2537,13 +2529,6 @@ void DialogsWidget::removeDialog(History *history) {
onFilterUpdate(); onFilterUpdate();
} }
void DialogsWidget::removeContact(UserData *user) {
_filter.setText(QString());
_filter.updatePlaceholder();
onFilterUpdate();
_inner.removeContact(user);
}
DialogsIndexed &DialogsWidget::contactsList() { DialogsIndexed &DialogsWidget::contactsList() {
return _inner.contactsList(); return _inner.contactsList();
} }

View File

@ -48,7 +48,6 @@ public:
void activate(); void activate();
void contactsReceived(const QVector<MTPContact> &contacts); void contactsReceived(const QVector<MTPContact> &contacts);
int32 addNewContact(int32 uid, bool sel = false); // -2 - err, -1 - don't scroll, >= 0 - scroll
int32 filteredOffset() const; int32 filteredOffset() const;
int32 peopleOffset() const; int32 peopleOffset() const;
@ -72,7 +71,6 @@ public:
void dlgUpdated(DialogRow *row); void dlgUpdated(DialogRow *row);
void dlgUpdated(History *row, MsgId msgId); void dlgUpdated(History *row, MsgId msgId);
void removeDialog(History *history); void removeDialog(History *history);
void removeContact(UserData *user);
void loadPeerPhotos(int32 yFrom); void loadPeerPhotos(int32 yFrom);
void clearFilter(); void clearFilter();
@ -123,6 +121,8 @@ public:
void updateNotifySettings(PeerData *peer); void updateNotifySettings(PeerData *peer);
void notify_userIsContactChanged(UserData *user, bool fromThisApp);
~DialogsInner(); ~DialogsInner();
public slots: public slots:
@ -220,7 +220,6 @@ public:
void contactsReceived(const MTPcontacts_Contacts &contacts); void contactsReceived(const MTPcontacts_Contacts &contacts);
void searchReceived(DialogsSearchRequestType type, const MTPmessages_Messages &result, mtpRequestId req); void searchReceived(DialogsSearchRequestType type, const MTPmessages_Messages &result, mtpRequestId req);
void peopleReceived(const MTPcontacts_Found &result, mtpRequestId req); void peopleReceived(const MTPcontacts_Found &result, mtpRequestId req);
bool addNewContact(int32 uid, bool show = true);
void dragEnterEvent(QDragEnterEvent *e); void dragEnterEvent(QDragEnterEvent *e);
void dragMoveEvent(QDragMoveEvent *e); void dragMoveEvent(QDragMoveEvent *e);
@ -251,7 +250,6 @@ public:
void scrollToPeer(const PeerId &peer, MsgId msgId); void scrollToPeer(const PeerId &peer, MsgId msgId);
void removeDialog(History *history); void removeDialog(History *history);
void removeContact(UserData *user);
DialogsIndexed &contactsList(); DialogsIndexed &contactsList();
DialogsIndexed &dialogsList(); DialogsIndexed &dialogsList();
@ -264,6 +262,8 @@ public:
void updateNotifySettings(PeerData *peer); void updateNotifySettings(PeerData *peer);
void notify_userIsContactChanged(UserData *user, bool fromThisApp);
signals: signals:
void cancelled(); void cancelled();

View File

@ -91,10 +91,20 @@ namespace Ui {
return false; 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) { 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->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 { namespace Notify {
@ -103,6 +113,10 @@ namespace Notify {
if (MainWidget *m = App::main()) m->notify_userIsBotChanged(user); 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) { void botCommandsChanged(UserData *user) {
if (MainWidget *m = App::main()) m->notify_botCommandsChanged(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); 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) { void historyItemLayoutChanged(const HistoryItem *item) {
if (MainWidget *m = App::main()) m->notify_historyItemLayoutChanged(item); if (MainWidget *m = App::main()) m->notify_historyItemLayoutChanged(item);
} }

View File

@ -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 showStickerPreview(DocumentData *sticker);
void hideStickerPreview(); void hideStickerPreview();
@ -46,16 +46,19 @@ namespace Ui { // it doesn't allow me to use UI :(
void hideLayer(bool fast = false); void hideLayer(bool fast = false);
bool isLayerShown(); bool isLayerShown();
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);
void showPeerHistoryAsync(const PeerId &peer, MsgId msgId);
}; };
namespace Notify { namespace Notify {
void userIsBotChanged(UserData *user); void userIsBotChanged(UserData *user);
void userIsContactChanged(UserData *user, bool fromThisApp = false);
void botCommandsChanged(UserData *user); void botCommandsChanged(UserData *user);
void migrateUpdated(PeerData *peer); void migrateUpdated(PeerData *peer);
void redrawHistoryItem(const HistoryItem *item);
void historyItemLayoutChanged(const HistoryItem *item); void historyItemLayoutChanged(const HistoryItem *item);
}; };

View File

@ -154,7 +154,7 @@ void AnimatedGif::step_frame(float64 ms, bool timer) {
frame = f; frame = f;
if (timer) { if (timer) {
if (msg) { if (msg) {
Notify::redrawHistoryItem(msg); Ui::redrawHistoryItem(msg);
} else { } else {
emit updated(); emit updated();
} }

View File

@ -2975,7 +2975,7 @@ void ItemAnimations::step_animate(float64 ms, bool timer) {
for (Animations::iterator i = _animations.begin(); i != _animations.end();) { for (Animations::iterator i = _animations.begin(); i != _animations.end();) {
const HistoryItem *item = i.key(); const HistoryItem *item = i.key();
if (item->animating()) { if (item->animating()) {
if (timer) Notify::redrawHistoryItem(item); if (timer) Ui::redrawHistoryItem(item);
++i; ++i;
} else { } else {
i = _animations.erase(i); 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); _animation->a_thumbOver.update(dt, anim::linear);
} }
if (timer) { if (timer) {
Notify::redrawHistoryItem(parent); Ui::redrawHistoryItem(parent);
} }
} }
@ -3769,7 +3769,7 @@ void HistoryFileMedia::step_radial(const HistoryItem *parent, uint64 ms, bool ti
checkAnimationFinished(); checkAnimationFinished();
} }
if (timer) { 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); QPixmap thumb = _contact->photo->pixRounded(st::msgFileThumbSize, st::msgFileThumbSize);
p.drawPixmap(rthumb.topLeft(), thumb); p.drawPixmap(rthumb.topLeft(), thumb);
} else { } 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) { if (selected) {
App::roundRect(p, rthumb, textstyleCurrent()->selectOverlay, SelectedOverlayCorners); 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; statustop = st::msgFileStatusTop;
QRect inner(rtlrect(st::msgFilePadding.left(), st::msgFilePadding.top(), st::msgFileSize, st::msgFileSize, width)); 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; int32 namewidth = width - nameleft - nameright;
@ -6566,7 +6566,7 @@ void HistoryMessage::setViewsCount(int32 count) {
_viewsText = (_views >= 0) ? formatViewsCount(_views) : QString(); _viewsText = (_views >= 0) ? formatViewsCount(_views) : QString();
_viewsWidth = _viewsText.isEmpty() ? 0 : st::msgDateFont->width(_viewsText); _viewsWidth = _viewsText.isEmpty() ? 0 : st::msgDateFont->width(_viewsText);
if (was == _viewsWidth) { if (was == _viewsWidth) {
Notify::redrawHistoryItem(this); Ui::redrawHistoryItem(this);
} else { } else {
if (_text.hasSkipBlock()) { if (_text.hasSkipBlock()) {
_text.setSkipBlock(HistoryMessage::skipBlockWidth(), HistoryMessage::skipBlockHeight()); _text.setSkipBlock(HistoryMessage::skipBlockWidth(), HistoryMessage::skipBlockHeight());
@ -6582,7 +6582,7 @@ void HistoryMessage::setId(MsgId newId) {
bool wasPositive = (id > 0), positive = (newId > 0); bool wasPositive = (id > 0), positive = (newId > 0);
HistoryItem::setId(newId); HistoryItem::setId(newId);
if (wasPositive == positive) { if (wasPositive == positive) {
Notify::redrawHistoryItem(this); Ui::redrawHistoryItem(this);
} else { } else {
if (_text.hasSkipBlock()) { if (_text.hasSkipBlock()) {
_text.setSkipBlock(HistoryMessage::skipBlockWidth(), HistoryMessage::skipBlockHeight()); _text.setSkipBlock(HistoryMessage::skipBlockWidth(), HistoryMessage::skipBlockHeight());

View File

@ -5451,7 +5451,7 @@ void HistoryWidget::onPhotoProgress(const FullMsgId &newId) {
if (!item->fromChannel()) { if (!item->fromChannel()) {
updateSendAction(item->history(), SendActionUploadPhoto, 0); updateSendAction(item->history(), SendActionUploadPhoto, 0);
} }
// Notify::redrawHistoryItem(item); // Ui::redrawHistoryItem(item);
} }
} }
@ -5473,7 +5473,7 @@ void HistoryWidget::onDocumentProgress(const FullMsgId &newId) {
if (!item->fromChannel()) { if (!item->fromChannel()) {
updateSendAction(item->history(), SendActionUploadFile, doc ? doc->uploadOffset : 0); 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()) { if (!item->fromChannel()) {
updateSendAction(item->history(), SendActionUploadAudio, audio ? audio->uploadOffset : 0); 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()) { if (!item->fromChannel()) {
updateSendAction(item->history(), SendActionUploadPhoto, -1); updateSendAction(item->history(), SendActionUploadPhoto, -1);
} }
// Notify::redrawHistoryItem(item); // Ui::redrawHistoryItem(item);
} }
} }
@ -5506,7 +5506,7 @@ void HistoryWidget::onDocumentFailed(const FullMsgId &newId) {
if (!item->fromChannel()) { if (!item->fromChannel()) {
updateSendAction(item->history(), SendActionUploadFile, -1); updateSendAction(item->history(), SendActionUploadFile, -1);
} }
Notify::redrawHistoryItem(item); Ui::redrawHistoryItem(item);
} }
} }
@ -5517,7 +5517,7 @@ void HistoryWidget::onAudioFailed(const FullMsgId &newId) {
if (!item->fromChannel()) { if (!item->fromChannel()) {
updateSendAction(item->history(), SendActionUploadAudio, -1); updateSendAction(item->history(), SendActionUploadAudio, -1);
} }
Notify::redrawHistoryItem(item); Ui::redrawHistoryItem(item);
} }
} }
@ -5604,7 +5604,7 @@ void HistoryWidget::peerMessagesUpdated() {
if (_list) peerMessagesUpdated(_peer->id); 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))) { if (_peer && _list && (item->history() == _history || (_migrated && item->history() == _migrated))) {
_list->redrawItem(item); _list->redrawItem(item);
} }
@ -6543,7 +6543,7 @@ void HistoryWidget::onAnimActiveStep() {
if (getms() - _animActiveStart > st::activeFadeInDuration + st::activeFadeOutDuration) { if (getms() - _animActiveStart > st::activeFadeInDuration + st::activeFadeOutDuration) {
stopAnimActive(); stopAnimActive();
} else { } else {
Notify::redrawHistoryItem(item); Ui::redrawHistoryItem(item);
} }
} }

View File

@ -430,8 +430,6 @@ public:
void peerMessagesUpdated(PeerId peer); void peerMessagesUpdated(PeerId peer);
void peerMessagesUpdated(); void peerMessagesUpdated();
void notify_redrawHistoryItem(const HistoryItem *item);
void notify_historyItemLayoutChanged(const HistoryItem *item);
void newUnreadMsg(History *history, HistoryItem *item); void newUnreadMsg(History *history, HistoryItem *item);
void historyToDown(History *history); void historyToDown(History *history);
void historyWasRead(bool force = true); void historyWasRead(bool force = true);
@ -559,6 +557,9 @@ public:
resizeEvent(0); resizeEvent(0);
} }
void ui_redrawHistoryItem(const HistoryItem *item);
void notify_historyItemLayoutChanged(const HistoryItem *item);
void notify_botCommandsChanged(UserData *user); void notify_botCommandsChanged(UserData *user);
void notify_userIsBotChanged(UserData *user); void notify_userIsBotChanged(UserData *user);
void notify_migrateUpdated(PeerData *peer); void notify_migrateUpdated(PeerData *peer);

View File

@ -754,18 +754,37 @@ void MainWidget::notify_userIsBotChanged(UserData *bot) {
history.notify_userIsBotChanged(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) { void MainWidget::notify_migrateUpdated(PeerData *peer) {
history.notify_migrateUpdated(peer); history.notify_migrateUpdated(peer);
} }
void MainWidget::notify_redrawHistoryItem(const HistoryItem *item) { void MainWidget::ui_redrawHistoryItem(const HistoryItem *item) {
if (!item) return; if (!item) return;
history.notify_redrawHistoryItem(item); history.ui_redrawHistoryItem(item);
if (!item->history()->dialogs.isEmpty() && item->history()->lastMsg == item) { if (!item->history()->dialogs.isEmpty() && item->history()->lastMsg == item) {
dialogs.dlgUpdated(item->history()->dialogs[0]); 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) { 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)); 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<UserData*> &users) { void MainWidget::addParticipants(PeerData *chatOrChannel, const QVector<UserData*> &users) {
if (chatOrChannel->isChat()) { if (chatOrChannel->isChat()) {
for (QVector<UserData*>::const_iterator i = users.cbegin(), e = users.cend(); i != e; ++i) { for (QVector<UserData*>::const_iterator i = users.cbegin(), e = users.cend(); i != e; ++i) {
@ -1488,7 +1503,7 @@ void MainWidget::itemResized(HistoryItem *row, bool scrollToIt) {
if (overview) { if (overview) {
overview->itemResized(row, scrollToIt); overview->itemResized(row, scrollToIt);
} }
if (row) Notify::redrawHistoryItem(row); if (row) Ui::redrawHistoryItem(row);
} }
bool MainWidget::overviewFailed(PeerData *peer, const RPCError &error, mtpRequestId req) { 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); VideoItems::const_iterator i = items.constFind(video);
if (i != items.cend()) { if (i != items.cend()) {
for (HistoryItemsMap::const_iterator j = i->cbegin(), e = i->cend(); j != e; ++j) { 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); Ui::showLayer(box);
} }
void MainWidget::ui_showPeerHistoryAsync(quint64 peerId, qint32 showAtMsgId) {
Ui::showPeerHistory(peerId, showAtMsgId);
}
void MainWidget::videoLoadFailed(mtpFileLoader *loader, bool started) { void MainWidget::videoLoadFailed(mtpFileLoader *loader, bool started) {
loadFailed(loader, started, SLOT(videoLoadRetry())); loadFailed(loader, started, SLOT(videoLoadRetry()));
VideoData *video = App::video(loader->objId()); VideoData *video = App::video(loader->objId());
@ -1715,7 +1734,7 @@ void MainWidget::audioLoadProgress(mtpFileLoader *loader) {
AudioItems::const_iterator i = items.constFind(audio); AudioItems::const_iterator i = items.constFind(audio);
if (i != items.cend()) { if (i != items.cend()) {
for (HistoryItemsMap::const_iterator j = i->cbegin(), e = i->cend(); j != e; ++j) { 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)) { 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)) { 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); DocumentItems::const_iterator i = items.constFind(document);
if (i != items.cend()) { if (i != items.cend()) {
for (HistoryItemsMap::const_iterator j = i->cbegin(), e = i->cend(); j != e; ++j) { 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); App::wnd()->documentUpdated(document);
@ -3941,12 +3960,6 @@ void MainWidget::updateOnlineDisplayIn(int32 msecs) {
_onlineUpdater.start(msecs); _onlineUpdater.start(msecs);
} }
void MainWidget::addNewContact(int32 uid, bool show) {
if (dialogs.addNewContact(uid, show)) {
showPeerHistory(peerFromUser(uid), ShowAtTheEndMsgId);
}
}
bool MainWidget::isActive() const { bool MainWidget::isActive() const {
return !_isIdle && isVisible() && !_a_show.animating(); return !_isIdle && isVisible() && !_a_show.animating();
} }
@ -4232,7 +4245,7 @@ void MainWidget::feedUpdate(const MTPUpdate &update) {
msgRow->history()->unregTyping(App::self()); msgRow->history()->unregTyping(App::self());
} }
if (!App::historyRegItem(msgRow)) { if (!App::historyRegItem(msgRow)) {
Notify::redrawHistoryItem(msgRow); Ui::redrawHistoryItem(msgRow);
} else { } else {
History *h = msgRow->history(); History *h = msgRow->history();
bool wasLast = (h->lastMsg == msgRow); 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 (HistoryItem *item = App::histItemById(NoChannel, v.at(i).v)) {
if (item->isMediaUnread()) { if (item->isMediaUnread()) {
item->markMediaRead(); item->markMediaRead();
Notify::redrawHistoryItem(item); Ui::redrawHistoryItem(item);
if (item->out() && item->history()->peer->isUser()) { if (item->out() && item->history()->peer->isUser()) {
item->history()->peer->asUser()->madeAction(); item->history()->peer->asUser()->madeAction();
} }

View File

@ -268,8 +268,6 @@ public:
void destroyData(); void destroyData();
void updateOnlineDisplayIn(int32 msecs); void updateOnlineDisplayIn(int32 msecs);
void addNewContact(int32 uid, bool show = true);
bool isActive() const; bool isActive() const;
bool historyIsActive() const; bool historyIsActive() const;
bool lastWasOnline() const; bool lastWasOnline() const;
@ -301,7 +299,6 @@ public:
void deletedContact(UserData *user, const MTPcontacts_Link &result); void deletedContact(UserData *user, const MTPcontacts_Link &result);
void deleteConversation(PeerData *peer, bool deleteHistory = true); void deleteConversation(PeerData *peer, bool deleteHistory = true);
void clearHistory(PeerData *peer); void clearHistory(PeerData *peer);
void removeContact(UserData *user);
void addParticipants(PeerData *chatOrChannel, const QVector<UserData*> &users); void addParticipants(PeerData *chatOrChannel, const QVector<UserData*> &users);
bool addParticipantFail(UserData *user, const RPCError &e); bool addParticipantFail(UserData *user, const RPCError &e);
@ -386,12 +383,6 @@ public:
void updateStickers(); 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 choosePeer(PeerId peerId, MsgId showAtMsgId); // does offerPeer or showPeerHistory
void clearBotStartToken(PeerData *peer); void clearBotStartToken(PeerData *peer);
@ -419,6 +410,13 @@ public:
void ui_showStickerPreview(DocumentData *sticker); void ui_showStickerPreview(DocumentData *sticker);
void ui_hideStickerPreview(); 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(); ~MainWidget();
@ -492,6 +490,8 @@ public slots:
void onDownloadPathSettings(); void onDownloadPathSettings();
void ui_showPeerHistoryAsync(quint64 peerId, qint32 showAtMsgId);
private: private:
void sendReadRequest(PeerData *peer, MsgId upTo); void sendReadRequest(PeerData *peer, MsgId upTo);

View File

@ -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) { if (peer() == msg->history()->peer || migratePeer() == msg->history()->peer) {
_inner.redrawItem(msg); _inner.redrawItem(msg);
} }

View File

@ -313,7 +313,6 @@ public:
void mediaOverviewUpdated(PeerData *peer, MediaOverviewType type); void mediaOverviewUpdated(PeerData *peer, MediaOverviewType type);
void changingMsgId(HistoryItem *row, MsgId newId); void changingMsgId(HistoryItem *row, MsgId newId);
void notify_redrawHistoryItem(const HistoryItem *msg);
void itemRemoved(HistoryItem *item); void itemRemoved(HistoryItem *item);
void itemResized(HistoryItem *row, bool scrollToIt); void itemResized(HistoryItem *row, bool scrollToIt);
@ -341,6 +340,8 @@ public:
resizeEvent(0); resizeEvent(0);
} }
void ui_redrawHistoryItem(const HistoryItem *msg);
~OverviewWidget(); ~OverviewWidget();
public slots: public slots: