From 1c28d59ed2f99f74b2ed1bbcd63d42e702591af9 Mon Sep 17 00:00:00 2001 From: John Preston Date: Thu, 15 Oct 2015 02:15:28 +0200 Subject: [PATCH] fixed bad resizing calls, 0.9.6 stable version --- Telegram/SourceFiles/app.cpp | 15 +++++++++--- Telegram/SourceFiles/app.h | 2 +- Telegram/SourceFiles/mainwidget.cpp | 37 +++++++++++++++++++---------- 3 files changed, 38 insertions(+), 16 deletions(-) diff --git a/Telegram/SourceFiles/app.cpp b/Telegram/SourceFiles/app.cpp index 748fdbfc8a..f431ddd4ca 100644 --- a/Telegram/SourceFiles/app.cpp +++ b/Telegram/SourceFiles/app.cpp @@ -747,7 +747,7 @@ namespace App { } } - void checkEntitiesAndViewsUpdate(const MTPDmessage &m) { + bool checkEntitiesAndViewsUpdate(const MTPDmessage &m) { PeerId peerId = peerFromMTP(m.vto_id); if (m.has_from_id() && peerToUser(peerId) == MTP::authedId()) { peerId = peerFromUser(m.vfrom_id); @@ -766,7 +766,10 @@ namespace App { existing->updateMedia(m.has_media() ? (&m.vmedia) : 0, true); existing->setViewsCount(m.has_views() ? m.vviews.v : -1); + + return !existing->detached(); } + return false; } void feedMsgs(const MTPVector &msgs, NewMessageType type) { @@ -777,9 +780,15 @@ namespace App { switch (msg.type()) { case mtpc_message: { const MTPDmessage &d(msg.c_message()); - msgsIds.insert((uint64(uint32(d.vid.v)) << 32) | uint64(i), i); + bool needToAdd = true; if (type == NewMessageUnread) { // new message, index my forwarded messages to links overview - checkEntitiesAndViewsUpdate(d); + if (checkEntitiesAndViewsUpdate(d)) { // already in blocks + LOG(("Skipping message, because it is already in blocks!")); + needToAdd = false; + } + } + if (needToAdd) { + msgsIds.insert((uint64(uint32(d.vid.v)) << 32) | uint64(i), i); } } break; case mtpc_messageEmpty: msgsIds.insert((uint64(uint32(msg.c_messageEmpty().vid.v)) << 32) | uint64(i), i); break; diff --git a/Telegram/SourceFiles/app.h b/Telegram/SourceFiles/app.h index 3c429b0b46..e8f085dec9 100644 --- a/Telegram/SourceFiles/app.h +++ b/Telegram/SourceFiles/app.h @@ -105,7 +105,7 @@ namespace App { void feedParticipants(const MTPChatParticipants &p, bool requestBotInfos, bool emitPeerUpdated = true); void feedParticipantAdd(const MTPDupdateChatParticipantAdd &d, bool emitPeerUpdated = true); void feedParticipantDelete(const MTPDupdateChatParticipantDelete &d, bool emitPeerUpdated = true); - void checkEntitiesAndViewsUpdate(const MTPDmessage &m); + bool checkEntitiesAndViewsUpdate(const MTPDmessage &m); // returns true if item found and it is not detached void feedMsgs(const MTPVector &msgs, NewMessageType type); void feedInboxRead(const PeerId &peer, MsgId upTo); void feedOutboxRead(const PeerId &peer, MsgId upTo); diff --git a/Telegram/SourceFiles/mainwidget.cpp b/Telegram/SourceFiles/mainwidget.cpp index 2dc54ce2b4..b0c0025908 100644 --- a/Telegram/SourceFiles/mainwidget.cpp +++ b/Telegram/SourceFiles/mainwidget.cpp @@ -3091,8 +3091,11 @@ void MainWidget::gotChannelDifference(ChannelData *channel, const MTPupdates_Cha switch (msg.type()) { case mtpc_message: { const MTPDmessage &d(msg.c_message()); - msgsIds.insert((uint64(uint32(d.vid.v)) << 32) | uint64(i), i + 1); - App::checkEntitiesAndViewsUpdate(d); // new message, index my forwarded messages to links overview + if (App::checkEntitiesAndViewsUpdate(d)) { // new message, index my forwarded messages to links overview, already in blocks + LOG(("Skipping message, because it is already in blocks!")); + } else { + msgsIds.insert((uint64(uint32(d.vid.v)) << 32) | uint64(i), i + 1); + } } break; case mtpc_messageEmpty: msgsIds.insert((uint64(uint32(msg.c_messageEmpty().vid.v)) << 32) | uint64(i), i + 1); break; case mtpc_messageService: msgsIds.insert((uint64(uint32(msg.c_messageService().vid.v)) << 32) | uint64(i), i + 1); break; @@ -4202,14 +4205,19 @@ void MainWidget::feedUpdate(const MTPUpdate &update) { } // update before applying skipped + bool needToAdd = true; if (d.vmessage.type() == mtpc_message) { // index forwarded messages to links overview - App::checkEntitiesAndViewsUpdate(d.vmessage.c_message()); + if (App::checkEntitiesAndViewsUpdate(d.vmessage.c_message())) { // already in blocks + LOG(("Skipping message, because it is already in blocks!")); + needToAdd = false; + } } - HistoryItem *item = App::histories().addNewMessage(d.vmessage, NewMessageUnread); - if (item) { - history.peerMessagesUpdated(item->history()->peer->id); + if (needToAdd) { + HistoryItem *item = App::histories().addNewMessage(d.vmessage, NewMessageUnread); + if (item) { + history.peerMessagesUpdated(item->history()->peer->id); + } } - ptsApplySkippedUpdates(); } break; @@ -4562,14 +4570,19 @@ void MainWidget::feedUpdate(const MTPUpdate &update) { } // update before applying skipped + bool needToAdd = true; if (d.vmessage.type() == mtpc_message) { // index forwarded messages to links overview - App::checkEntitiesAndViewsUpdate(d.vmessage.c_message()); + if (App::checkEntitiesAndViewsUpdate(d.vmessage.c_message())) { // already in blocks + LOG(("Skipping message, because it is already in blocks!")); + needToAdd = false; + } } - HistoryItem *item = App::histories().addNewMessage(d.vmessage, NewMessageUnread); - if (item) { - history.peerMessagesUpdated(item->history()->peer->id); + if (needToAdd) { + HistoryItem *item = App::histories().addNewMessage(d.vmessage, NewMessageUnread); + if (item) { + history.peerMessagesUpdated(item->history()->peer->id); + } } - if (channel && !_handlingChannelDifference) { channel->ptsApplySkippedUpdates(); }