Skip to content

Commit

Permalink
fixed bug in history size count, 0.9.5
Browse files Browse the repository at this point in the history
  • Loading branch information
john-preston committed Oct 14, 2015
1 parent 21570c0 commit bf6bebb
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 11 deletions.
2 changes: 1 addition & 1 deletion Telegram/SourceFiles/app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -763,7 +763,7 @@ namespace App {
}
}

existing->updateMedia(m.has_media() ? (&m.vmedia) : 0);
existing->updateMedia(m.has_media() ? (&m.vmedia) : 0, true);

existing->setViewsCount(m.has_views() ? m.vviews.v : -1);
}
Expand Down
6 changes: 3 additions & 3 deletions Telegram/SourceFiles/history.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1345,7 +1345,7 @@ HistoryItem *History::createItem(HistoryBlock *block, const MTPMessage &msg, boo
}

if (msg.type() == mtpc_message) {
existing->updateMedia(msg.c_message().has_media() ? (&msg.c_message().vmedia) : 0);
existing->updateMedia(msg.c_message().has_media() ? (&msg.c_message().vmedia) : 0, (block ? false : true));
}
return (returnExisting || regged) ? existing : 0;
}
Expand Down Expand Up @@ -6259,7 +6259,7 @@ HistoryMedia *HistoryMessage::getMedia(bool inOverview) const {
return _media;
}

void HistoryMessage::setMedia(const MTPMessageMedia *media) {
void HistoryMessage::setMedia(const MTPMessageMedia *media, bool allowEmitResize) {
if ((!_media || _media->isImageLink()) && (!media || media->type() == mtpc_messageMediaEmpty)) return;

bool mediaWasDisplayed = false;
Expand All @@ -6280,7 +6280,7 @@ void HistoryMessage::setMedia(const MTPMessageMedia *media) {
_textHeight = 0;
}
initDimensions();
if (App::main()) App::main()->itemResized(this);
if (allowEmitResize && App::main()) App::main()->itemResized(this);
}

void HistoryMessage::setText(const QString &text, const LinksInText &links) {
Expand Down
10 changes: 4 additions & 6 deletions Telegram/SourceFiles/history.h
Original file line number Diff line number Diff line change
Expand Up @@ -880,7 +880,7 @@ class HistoryItem : public HistoryElem {
virtual bool serviceMsg() const {
return false;
}
virtual void updateMedia(const MTPMessageMedia *media) {
virtual void updateMedia(const MTPMessageMedia *media, bool allowEmitResize) {
}

virtual QString selectedText(uint32 selection) const {
Expand Down Expand Up @@ -930,8 +930,6 @@ class HistoryItem : public HistoryElem {
virtual HistoryMedia *getMedia(bool inOverview = false) const {
return 0;
}
virtual void setMedia(const MTPMessageMedia *media) {
}
virtual void setText(const QString &text, const LinksInText &links) {
}
virtual void getTextWithLinks(QString &text, LinksInText &links) {
Expand Down Expand Up @@ -1541,19 +1539,19 @@ class HistoryMessage : public HistoryItem {
QString notificationHeader() const;
QString notificationText() const;

void updateMedia(const MTPMessageMedia *media) {
void updateMedia(const MTPMessageMedia *media, bool allowEmitResize) {
if (media && _media && _media->type() != MediaTypeWebPage) {
_media->updateFrom(*media);
} else {
setMedia(media);
setMedia(media, allowEmitResize);
}
}

QString selectedText(uint32 selection) const;
LinksInText textLinks() const;
QString inDialogsText() const;
HistoryMedia *getMedia(bool inOverview = false) const;
void setMedia(const MTPMessageMedia *media);
void setMedia(const MTPMessageMedia *media, bool allowEmitResize);
void setText(const QString &text, const LinksInText &links);
void getTextWithLinks(QString &text, LinksInText &links);
bool textHasLinks();
Expand Down
2 changes: 1 addition & 1 deletion Telegram/SourceFiles/mainwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4169,7 +4169,7 @@ void MainWidget::feedUpdates(const MTPUpdates &updates, uint64 randomId) {
}
}

item->updateMedia(d.has_media() ? (&d.vmedia) : 0);
item->updateMedia(d.has_media() ? (&d.vmedia) : 0, true);
}
}
}
Expand Down

0 comments on commit bf6bebb

Please sign in to comment.