not loaded thumbs are now white, always initDimensions() when media is updated

This commit is contained in:
John Preston 2016-01-09 15:11:23 +08:00
parent a39810a9c5
commit f66c54ee6b
6 changed files with 110 additions and 95 deletions

View file

@ -902,12 +902,12 @@ namespace App {
} }
if (HistoryItem *existing = App::histItemById(peerToChannel(peerId), m.vid.v)) { if (HistoryItem *existing = App::histItemById(peerToChannel(peerId), m.vid.v)) {
existing->setText(qs(m.vmessage), m.has_entities() ? entitiesFromMTP(m.ventities.c_vector().v) : EntitiesInText()); existing->setText(qs(m.vmessage), m.has_entities() ? entitiesFromMTP(m.ventities.c_vector().v) : EntitiesInText());
existing->updateMedia(m.has_media() ? (&m.vmedia) : 0);
existing->setViewsCount(m.has_views() ? m.vviews.v : -1, false);
existing->initDimensions(); existing->initDimensions();
Notify::historyItemResized(existing); Notify::historyItemResized(existing);
existing->updateMedia(m.has_media() ? (&m.vmedia) : 0, true);
existing->addToOverview(AddToOverviewNew); existing->addToOverview(AddToOverviewNew);
existing->setViewsCount(m.has_views() ? m.vviews.v : -1);
if (!existing->detached()) { if (!existing->detached()) {
App::checkSavedGif(existing); App::checkSavedGif(existing);
@ -929,6 +929,8 @@ namespace App {
Local::writeSavedGifs(); Local::writeSavedGifs();
if (App::main()) emit App::main()->savedGifsUpdated(); if (App::main()) emit App::main()->savedGifsUpdated();
cSetLastSavedGifsUpdate(0);
App::main()->updateStickers();
} }
} }

View file

@ -311,21 +311,19 @@ void EmojiButton::paintEvent(QPaintEvent *e) {
p.drawPixmap(t, App::sprite(), i); p.drawPixmap(t, App::sprite(), i);
} }
QRect inner(QPoint((width() - st::emojiCircle.width()) / 2, st::emojiCircleTop), st::emojiCircle);
int32 full = 5760;
int32 start = qRound(full * float64(ms % uint64(st::emojiCirclePeriod)) / st::emojiCirclePeriod), part = qRound(full / st::emojiCirclePart);
p.setBrush(Qt::NoBrush);
p.setRenderHint(QPainter::HighQualityAntialiasing);
p.setPen(QPen(st::emojiCircleFg->c, st::emojiCircleLine));
p.setOpacity(a_opacity.current() * _opacity); p.setOpacity(a_opacity.current() * _opacity);
p.drawEllipse(inner); p.setPen(QPen(st::emojiCircleFg, st::emojiCircleLine));
p.setBrush(Qt::NoBrush);
p.setPen(QPen(st::white->c, st::emojiCircleLine));
p.setOpacity(loading);
p.drawArc(inner, (full - start) % full, part);
p.setRenderHint(QPainter::HighQualityAntialiasing);
QRect inner(QPoint((width() - st::emojiCircle.width()) / 2, st::emojiCircleTop), st::emojiCircle);
if (loading > 0) {
int32 full = 5760;
int32 start = qRound(full * float64(ms % uint64(st::emojiCirclePeriod)) / st::emojiCirclePeriod), part = qRound(loading * full / st::emojiCirclePart);
p.drawArc(inner, start, full - part);
} else {
p.drawEllipse(inner);
}
p.setRenderHint(QPainter::HighQualityAntialiasing, false); p.setRenderHint(QPainter::HighQualityAntialiasing, false);
} }

View file

@ -365,7 +365,7 @@ yi += stride;
#undef update #undef update
} }
delete[] rgb; delete[] rgb;
} }
} }
@ -444,7 +444,7 @@ QPixmap imagePix(QImage img, int32 w, int32 h, bool smooth, bool blurred, bool r
{ {
QPainter p(&result); QPainter p(&result);
if (w < outerw || h < outerh) { if (w < outerw || h < outerh) {
p.fillRect(0, 0, result.width(), result.height(), st::black->b); p.fillRect(0, 0, result.width(), result.height(), st::black);
} }
p.drawImage((result.width() - img.width()) / (2 * cIntRetinaFactor()), (result.height() - img.height()) / (2 * cIntRetinaFactor()), img); p.drawImage((result.width() - img.width()) / (2 * cIntRetinaFactor()), (result.height() - img.height()) / (2 * cIntRetinaFactor()), img);
} }
@ -459,7 +459,12 @@ QPixmap imagePix(QImage img, int32 w, int32 h, bool smooth, bool blurred, bool r
QPixmap Image::pixNoCache(int32 w, int32 h, bool smooth, bool blurred, bool rounded, int32 outerw, int32 outerh) const { QPixmap Image::pixNoCache(int32 w, int32 h, bool smooth, bool blurred, bool rounded, int32 outerw, int32 outerh) const {
if (!loading()) const_cast<Image*>(this)->load(); if (!loading()) const_cast<Image*>(this)->load();
restore(); restore();
if (_data.isNull()) return blank()->pix(); if (_data.isNull()) {
if (h <= 0 && height() > 0) {
h = qRound(width() * w / float64(height()));
}
return blank()->pixNoCache(w, h, smooth, blurred, rounded, outerw, outerh);
}
if (isNull() && outerw > 0 && outerh > 0) { if (isNull() && outerw > 0 && outerh > 0) {
outerw *= cIntRetinaFactor(); outerw *= cIntRetinaFactor();
@ -470,7 +475,15 @@ QPixmap Image::pixNoCache(int32 w, int32 h, bool smooth, bool blurred, bool roun
{ {
QPainter p(&result); QPainter p(&result);
p.fillRect(0, 0, result.width(), result.height(), st::black); if (w < outerw) {
p.fillRect(0, 0, (outerw - w) / 2, result.height(), st::black);
p.fillRect(((outerw - w) / 2) + w, 0, result.width() - (((outerw - w) / 2) + w), result.height(), st::black);
}
if (h < outerh) {
p.fillRect(qMax(0, (outerw - w) / 2), 0, qMin(result.width(), w), (outerh - h) / 2, st::black);
p.fillRect(qMax(0, (outerw - w) / 2), ((outerh - h) / 2) + h, qMin(result.width(), w), result.height() - (((outerh - h) / 2) + h), st::black);
}
p.fillRect(qMax(0, (outerw - w) / 2), qMax(0, (outerh - h) / 2), qMin(result.width(), w), qMin(result.height(), h), st::white);
} }
if (rounded) imageRound(result); if (rounded) imageRound(result);

View file

@ -1318,7 +1318,11 @@ HistoryItem *History::createItem(HistoryBlock *block, const MTPMessage &msg, boo
result->attach(block); result->attach(block);
} }
if (msg.type() == mtpc_message) { if (msg.type() == mtpc_message) {
result->updateMedia(msg.c_message().has_media() ? (&msg.c_message().vmedia) : 0, (block ? false : true)); result->updateMedia(msg.c_message().has_media() ? (&msg.c_message().vmedia) : 0);
result->initDimensions();
if (!block) {
Notify::historyItemResized(result);
}
if (applyServiceAction) { if (applyServiceAction) {
App::checkSavedGif(result); App::checkSavedGif(result);
} }
@ -3430,7 +3434,7 @@ void HistoryPhoto::getState(TextLinkPtr &lnk, HistoryCursorState &state, int32 x
} }
} }
void HistoryPhoto::updateFrom(const MTPMessageMedia &media, HistoryItem *parent, bool allowEmitResize) { void HistoryPhoto::updateFrom(const MTPMessageMedia &media, HistoryItem *parent) {
if (media.type() == mtpc_messageMediaPhoto) { if (media.type() == mtpc_messageMediaPhoto) {
const MTPPhoto &photo(media.c_messageMediaPhoto().vphoto); const MTPPhoto &photo(media.c_messageMediaPhoto().vphoto);
App::feedPhoto(photo, _data); App::feedPhoto(photo, _data);
@ -3628,9 +3632,7 @@ void HistoryVideo::draw(Painter &p, const HistoryItem *parent, const QRect &r, b
} }
QRect rthumb(rtlrect(skipx, skipy, width, height, _width)); QRect rthumb(rtlrect(skipx, skipy, width, height, _width));
p.drawPixmap(rthumb.topLeft(), _data->thumb->pixBlurredSingle(_thumbw, 0, width, height));
QPixmap pix = _data->thumb->pixBlurredSingle(_thumbw, 0, width, height);
p.drawPixmap(rthumb.topLeft(), pix);
if (selected) { if (selected) {
App::roundRect(p, rthumb, textstyleCurrent()->selectOverlay, SelectedOverlayCorners); App::roundRect(p, rthumb, textstyleCurrent()->selectOverlay, SelectedOverlayCorners);
} }
@ -3929,7 +3931,7 @@ void HistoryAudio::unregItem(HistoryItem *item) {
App::unregAudioItem(_data, item); App::unregAudioItem(_data, item);
} }
void HistoryAudio::updateFrom(const MTPMessageMedia &media, HistoryItem *parent, bool allowEmitResize) { void HistoryAudio::updateFrom(const MTPMessageMedia &media, HistoryItem *parent) {
if (media.type() == mtpc_messageMediaAudio) { if (media.type() == mtpc_messageMediaAudio) {
App::feedAudio(media.c_messageMediaAudio().vaudio, _data); App::feedAudio(media.c_messageMediaAudio().vaudio, _data);
if (!_data->data().isEmpty()) { if (!_data->data().isEmpty()) {
@ -3990,18 +3992,6 @@ HistoryDocument::HistoryDocument(DocumentData *document, const QString &caption,
if (!caption.isEmpty()) { if (!caption.isEmpty()) {
_caption.setText(st::msgFont, caption + parent->skipBlock(), itemTextNoMonoOptions(parent)); _caption.setText(st::msgFont, caption + parent->skipBlock(), itemTextNoMonoOptions(parent));
} }
if (withThumb()) {
_data->thumb->load();
int32 tw = _data->thumb->width(), th = _data->thumb->height();
if (tw > th) {
_thumbw = (tw * st::msgFileThumbSize) / th;
} else {
_thumbw = st::msgFileThumbSize;
}
} else {
_thumbw = 0;
}
} }
HistoryDocument::HistoryDocument(const HistoryDocument &other) : HistoryFileMedia() HistoryDocument::HistoryDocument(const HistoryDocument &other) : HistoryFileMedia()
@ -4021,6 +4011,18 @@ void HistoryDocument::initDimensions(const HistoryItem *parent) {
_caption.setSkipBlock(parent->skipBlockWidth(), parent->skipBlockHeight()); _caption.setSkipBlock(parent->skipBlockWidth(), parent->skipBlockHeight());
} }
if (withThumb()) {
_data->thumb->load();
int32 tw = _data->thumb->width(), th = _data->thumb->height();
if (tw > th) {
_thumbw = (tw * st::msgFileThumbSize) / th;
} else {
_thumbw = st::msgFileThumbSize;
}
} else {
_thumbw = 0;
}
_maxw = st::msgFileMinWidth; _maxw = st::msgFileMinWidth;
int32 tleft = 0, tright = 0; int32 tleft = 0, tright = 0;
@ -4098,12 +4100,8 @@ void HistoryDocument::draw(Painter &p, const HistoryItem *parent, const QRect &r
bottom = st::msgFileThumbPadding.top() + st::msgFileThumbSize + st::msgFileThumbPadding.bottom(); bottom = st::msgFileThumbPadding.top() + st::msgFileThumbSize + st::msgFileThumbPadding.bottom();
QRect rthumb(rtlrect(st::msgFileThumbPadding.left(), st::msgFileThumbPadding.top(), st::msgFileThumbSize, st::msgFileThumbSize, _width)); QRect rthumb(rtlrect(st::msgFileThumbPadding.left(), st::msgFileThumbPadding.top(), st::msgFileThumbSize, st::msgFileThumbSize, _width));
if (_data->thumb->loaded()) { QPixmap thumb = loaded ? _data->thumb->pixSingle(_thumbw, 0, st::msgFileThumbSize, st::msgFileThumbSize) : _data->thumb->pixBlurredSingle(_thumbw, 0, st::msgFileThumbSize, st::msgFileThumbSize);
QPixmap thumb = loaded ? _data->thumb->pixSingle(_thumbw, 0, st::msgFileThumbSize, st::msgFileThumbSize) : _data->thumb->pixBlurredSingle(_thumbw, 0, st::msgFileThumbSize, st::msgFileThumbSize); p.drawPixmap(rthumb.topLeft(), thumb);
p.drawPixmap(rthumb.topLeft(), thumb);
} else {
App::roundRect(p, rthumb, st::black, BlackCorners);
}
if (selected) { if (selected) {
App::roundRect(p, rthumb, textstyleCurrent()->selectOverlay, SelectedOverlayCorners); App::roundRect(p, rthumb, textstyleCurrent()->selectOverlay, SelectedOverlayCorners);
} }
@ -4348,7 +4346,7 @@ void HistoryDocument::unregItem(HistoryItem *item) {
App::unregDocumentItem(_data, item); App::unregDocumentItem(_data, item);
} }
void HistoryDocument::updateFrom(const MTPMessageMedia &media, HistoryItem *parent, bool allowEmitResize) { void HistoryDocument::updateFrom(const MTPMessageMedia &media, HistoryItem *parent) {
if (media.type() == mtpc_messageMediaDocument) { if (media.type() == mtpc_messageMediaDocument) {
App::feedDocument(media.c_messageMediaDocument().vdocument, _data); App::feedDocument(media.c_messageMediaDocument().vdocument, _data);
} }
@ -4689,7 +4687,7 @@ void HistoryGif::unregItem(HistoryItem *item) {
App::unregDocumentItem(_data, item); App::unregDocumentItem(_data, item);
} }
void HistoryGif::updateFrom(const MTPMessageMedia &media, HistoryItem *parent, bool allowEmitResize) { void HistoryGif::updateFrom(const MTPMessageMedia &media, HistoryItem *parent) {
if (media.type() == mtpc_messageMediaDocument) { if (media.type() == mtpc_messageMediaDocument) {
App::feedDocument(media.c_messageMediaDocument().vdocument, _data); App::feedDocument(media.c_messageMediaDocument().vdocument, _data);
} }
@ -4884,7 +4882,7 @@ void HistorySticker::unregItem(HistoryItem *item) {
App::unregDocumentItem(_data, item); App::unregDocumentItem(_data, item);
} }
void HistorySticker::updateFrom(const MTPMessageMedia &media, HistoryItem *parent, bool allowEmitResize) { void HistorySticker::updateFrom(const MTPMessageMedia &media, HistoryItem *parent) {
if (media.type() == mtpc_messageMediaDocument) { if (media.type() == mtpc_messageMediaDocument) {
App::feedDocument(media.c_messageMediaDocument().vdocument, _data); App::feedDocument(media.c_messageMediaDocument().vdocument, _data);
if (!_data->data().isEmpty()) { if (!_data->data().isEmpty()) {
@ -5057,14 +5055,12 @@ void HistoryContact::unregItem(HistoryItem *item) {
} }
} }
void HistoryContact::updateFrom(const MTPMessageMedia &media, HistoryItem *parent, bool allowEmitResize) { void HistoryContact::updateFrom(const MTPMessageMedia &media, HistoryItem *parent) {
if (media.type() == mtpc_messageMediaContact) { if (media.type() == mtpc_messageMediaContact) {
if (_userId != media.c_messageMediaContact().vuser_id.v) { if (_userId != media.c_messageMediaContact().vuser_id.v) {
unregItem(parent); unregItem(parent);
_userId = media.c_messageMediaContact().vuser_id.v; _userId = media.c_messageMediaContact().vuser_id.v;
regItem(parent); regItem(parent);
parent->initDimensions();
if (allowEmitResize) Notify::historyItemResized(parent);
} }
} }
} }
@ -5887,7 +5883,7 @@ void HistoryImageLink::draw(Painter &p, const HistoryItem *parent, const QRect &
} }
p.drawPixmap(QPoint(skipx, skipy), pix); p.drawPixmap(QPoint(skipx, skipy), pix);
} else { } else {
App::roundRect(p, skipx, skipy, width, height, st::black, BlackCorners); App::roundRect(p, skipx, skipy, width, height, st::white, MessageInCorners);
} }
if (selected) { if (selected) {
App::roundRect(p, skipx, skipy, width, height, textstyleCurrent()->selectOverlay, SelectedOverlayCorners); App::roundRect(p, skipx, skipy, width, height, textstyleCurrent()->selectOverlay, SelectedOverlayCorners);
@ -6194,9 +6190,17 @@ void HistoryMessage::initDimensions() {
if (maxw > _maxw) _maxw = maxw; if (maxw > _maxw) _maxw = maxw;
_minh += _media->minHeight(); _minh += _media->minHeight();
} }
if (!_media && !displayFromName() && via() && !toHistoryForwarded()) { if (!_media) {
if (st::msgPadding.left() + via()->maxWidth + st::msgPadding.right() > _maxw) { if (displayFromName()) {
_maxw = st::msgPadding.left() + via()->maxWidth + st::msgPadding.right(); int32 namew = st::msgPadding.left() + _from->nameText.maxWidth() + st::msgPadding.right();
if (via() && !toHistoryForwarded()) {
namew += st::msgServiceFont->spacew + via()->maxWidth;
}
if (namew > _maxw) _maxw = namew;
} else if (via() && !toHistoryForwarded()) {
if (st::msgPadding.left() + via()->maxWidth + st::msgPadding.right() > _maxw) {
_maxw = st::msgPadding.left() + via()->maxWidth + st::msgPadding.right();
}
} }
} }
} else { } else {
@ -6204,7 +6208,6 @@ void HistoryMessage::initDimensions() {
_maxw = _media->maxWidth(); _maxw = _media->maxWidth();
_minh = _media->minHeight(); _minh = _media->minHeight();
} }
fromNameUpdated();
} }
void HistoryMessage::countPositionAndSize(int32 &left, int32 &width) const { void HistoryMessage::countPositionAndSize(int32 &left, int32 &width) const {
@ -6227,13 +6230,12 @@ void HistoryMessage::countPositionAndSize(int32 &left, int32 &width) const {
} }
} }
void HistoryMessage::fromNameUpdated() const { void HistoryMessage::fromNameUpdated(int32 width) const {
if (!_media && displayFromName()) { _fromVersion = _from->nameVersion;
int32 namew = st::msgPadding.left() + _from->nameText.maxWidth() + st::msgPadding.right(); if (drawBubble() && displayFromName()) {
if (via() && !toHistoryForwarded()) { if (via() && !toHistoryForwarded()) {
namew += st::msgServiceFont->spacew + via()->maxWidth; via()->resize(width - st::msgPadding.left() - st::msgPadding.right() - _from->nameText.maxWidth() - st::msgServiceFont->spacew);
} }
if (namew > _maxw) _maxw = namew;
} }
} }
@ -6287,7 +6289,7 @@ HistoryMedia *HistoryMessage::getMedia(bool inOverview) const {
return _media; return _media;
} }
void HistoryMessage::setMedia(const MTPMessageMedia *media, bool allowEmitResize) { void HistoryMessage::setMedia(const MTPMessageMedia *media) {
if ((!_media || _media->isImageLink()) && (!media || media->type() == mtpc_messageMediaEmpty)) return; if ((!_media || _media->isImageLink()) && (!media || media->type() == mtpc_messageMediaEmpty)) return;
bool mediaWasDisplayed = false; bool mediaWasDisplayed = false;
@ -6307,8 +6309,6 @@ void HistoryMessage::setMedia(const MTPMessageMedia *media, bool allowEmitResize
_textWidth = 0; _textWidth = 0;
_textHeight = 0; _textHeight = 0;
} }
initDimensions();
if (allowEmitResize) Notify::historyItemResized(this);
} }
void HistoryMessage::setText(const QString &text, const EntitiesInText &entities) { void HistoryMessage::setText(const QString &text, const EntitiesInText &entities) {
@ -6413,7 +6413,7 @@ void HistoryMessage::drawInfo(Painter &p, int32 right, int32 bottom, int32 width
} }
} }
void HistoryMessage::setViewsCount(int32 count) { void HistoryMessage::setViewsCount(int32 count, bool reinit) {
if (_views == count || (count >= 0 && _views > count)) return; if (_views == count || (count >= 0 && _views > count)) return;
int32 was = _viewsWidth; int32 was = _viewsWidth;
@ -6428,8 +6428,10 @@ void HistoryMessage::setViewsCount(int32 count) {
_textWidth = 0; _textWidth = 0;
_textHeight = 0; _textHeight = 0;
} }
initDimensions(); if (reinit) {
Notify::historyItemResized(this); initDimensions();
Notify::historyItemResized(this);
}
} }
} }
@ -6468,13 +6470,12 @@ void HistoryMessage::draw(Painter &p, const QRect &r, uint32 selection, uint64 m
} }
} }
if (_from->nameVersion > _fromVersion) {
// fromNameUpdated();
_fromVersion = _from->nameVersion;
}
int32 left = 0, width = 0; int32 left = 0, width = 0;
countPositionAndSize(left, width); countPositionAndSize(left, width);
if (_from->nameVersion > _fromVersion) {
fromNameUpdated(width);
}
if (displayFromPhoto()) { if (displayFromPhoto()) {
p.drawPixmap(left - st::msgPhotoSkip, _height - st::msgMargin.bottom() - st::msgPhotoSize, _from->photo->pixRounded(st::msgPhotoSize)); p.drawPixmap(left - st::msgPhotoSkip, _height - st::msgMargin.bottom() - st::msgPhotoSize, _from->photo->pixRounded(st::msgPhotoSize));
} }
@ -6579,17 +6580,19 @@ int32 HistoryMessage::resize(int32 width) {
} }
if (media) _height += _media->resize(width, this); if (media) _height += _media->resize(width, this);
} }
int32 l = 0, w = 0;
countPositionAndSize(l, w);
if (displayFromName()) { if (displayFromName()) {
if (emptyText()) { if (emptyText()) {
_height += st::msgPadding.top() + st::msgNameFont->height + st::mediaHeaderSkip; _height += st::msgPadding.top() + st::msgNameFont->height + st::mediaHeaderSkip;
} else { } else {
_height += st::msgNameFont->height; _height += st::msgNameFont->height;
} }
if (via() && !toHistoryForwarded()) { fromNameUpdated(w);
via()->resize(width - st::msgPadding.left() - st::msgPadding.right() - _from->nameText.maxWidth() - st::msgServiceFont->spacew);
}
} else if (via() && !toHistoryForwarded()) { } else if (via() && !toHistoryForwarded()) {
via()->resize(width - st::msgPadding.left() - st::msgPadding.right()); via()->resize(w - st::msgPadding.left() - st::msgPadding.right());
if (emptyText() && !displayFromName()) { if (emptyText() && !displayFromName()) {
_height += st::msgPadding.top() + st::msgNameFont->height + st::mediaHeaderSkip; _height += st::msgPadding.top() + st::msgNameFont->height + st::mediaHeaderSkip;
} else { } else {

View file

@ -897,7 +897,7 @@ public:
virtual bool serviceMsg() const { virtual bool serviceMsg() const {
return false; return false;
} }
virtual void updateMedia(const MTPMessageMedia *media, bool allowEmitResize) { virtual void updateMedia(const MTPMessageMedia *media) {
} }
virtual int32 addToOverview(AddToOverviewMethod method) { virtual int32 addToOverview(AddToOverviewMethod method) {
return 0; return 0;
@ -918,7 +918,7 @@ public:
virtual void drawInfo(Painter &p, int32 right, int32 bottom, int32 width, bool selected, InfoDisplayType type) const { virtual void drawInfo(Painter &p, int32 right, int32 bottom, int32 width, bool selected, InfoDisplayType type) const {
} }
virtual void setViewsCount(int32 count) { virtual void setViewsCount(int32 count, bool reinit = true) {
} }
virtual void setId(MsgId newId); virtual void setId(MsgId newId);
virtual void setDate(const QDateTime &date) { // for date items virtual void setDate(const QDateTime &date) { // for date items
@ -1161,7 +1161,7 @@ public:
virtual void unregItem(HistoryItem *item) { virtual void unregItem(HistoryItem *item) {
} }
virtual void updateFrom(const MTPMessageMedia &media, HistoryItem *parent, bool allowEmitResize) { virtual void updateFrom(const MTPMessageMedia &media, HistoryItem *parent) {
} }
virtual bool isImageLink() const { virtual bool isImageLink() const {
@ -1309,7 +1309,7 @@ public:
return _data; return _data;
} }
void updateFrom(const MTPMessageMedia &media, HistoryItem *parent, bool allowEmitResize); void updateFrom(const MTPMessageMedia &media, HistoryItem *parent);
void regItem(HistoryItem *item); void regItem(HistoryItem *item);
void unregItem(HistoryItem *item); void unregItem(HistoryItem *item);
@ -1451,7 +1451,7 @@ public:
void regItem(HistoryItem *item); void regItem(HistoryItem *item);
void unregItem(HistoryItem *item); void unregItem(HistoryItem *item);
void updateFrom(const MTPMessageMedia &media, HistoryItem *parent, bool allowEmitResize); void updateFrom(const MTPMessageMedia &media, HistoryItem *parent);
bool needsBubble(const HistoryItem *parent) const { bool needsBubble(const HistoryItem *parent) const {
return true; return true;
@ -1519,7 +1519,7 @@ public:
void regItem(HistoryItem *item); void regItem(HistoryItem *item);
void unregItem(HistoryItem *item); void unregItem(HistoryItem *item);
void updateFrom(const MTPMessageMedia &media, HistoryItem *parent, bool allowEmitResize); void updateFrom(const MTPMessageMedia &media, HistoryItem *parent);
bool hasReplyPreview() const { bool hasReplyPreview() const {
return !_data->thumb->isNull(); return !_data->thumb->isNull();
@ -1611,7 +1611,7 @@ public:
void regItem(HistoryItem *item); void regItem(HistoryItem *item);
void unregItem(HistoryItem *item); void unregItem(HistoryItem *item);
void updateFrom(const MTPMessageMedia &media, HistoryItem *parent, bool allowEmitResize); void updateFrom(const MTPMessageMedia &media, HistoryItem *parent);
bool hasReplyPreview() const { bool hasReplyPreview() const {
return !_data->thumb->isNull(); return !_data->thumb->isNull();
@ -1686,7 +1686,7 @@ public:
void regItem(HistoryItem *item); void regItem(HistoryItem *item);
void unregItem(HistoryItem *item); void unregItem(HistoryItem *item);
void updateFrom(const MTPMessageMedia &media, HistoryItem *parent, bool allowEmitResize); void updateFrom(const MTPMessageMedia &media, HistoryItem *parent);
bool needsBubble(const HistoryItem *parent) const { bool needsBubble(const HistoryItem *parent) const {
return false; return false;
@ -1745,7 +1745,7 @@ public:
void regItem(HistoryItem *item); void regItem(HistoryItem *item);
void unregItem(HistoryItem *item); void unregItem(HistoryItem *item);
void updateFrom(const MTPMessageMedia &media, HistoryItem *parent, bool allowEmitResize); void updateFrom(const MTPMessageMedia &media, HistoryItem *parent);
bool needsBubble(const HistoryItem *parent) const { bool needsBubble(const HistoryItem *parent) const {
return true; return true;
@ -1988,7 +1988,7 @@ public:
void initMedia(const MTPMessageMedia *media, QString &currentText); void initMedia(const MTPMessageMedia *media, QString &currentText);
void initMediaFromDocument(DocumentData *doc, const QString &caption); void initMediaFromDocument(DocumentData *doc, const QString &caption);
void initDimensions(); void initDimensions();
void fromNameUpdated() const; void fromNameUpdated(int32 width) const;
virtual HistoryMessageVia *via() const { virtual HistoryMessageVia *via() const {
return (_via && !_via->isNull()) ? _via : 0; return (_via && !_via->isNull()) ? _via : 0;
@ -2017,7 +2017,7 @@ public:
} }
void drawInfo(Painter &p, int32 right, int32 bottom, int32 width, bool selected, InfoDisplayType type) const; void drawInfo(Painter &p, int32 right, int32 bottom, int32 width, bool selected, InfoDisplayType type) const;
void setViewsCount(int32 count); void setViewsCount(int32 count, bool reinit = true);
void setId(MsgId newId); void setId(MsgId newId);
void draw(Painter &p, const QRect &r, uint32 selection, uint64 ms) const; void draw(Painter &p, const QRect &r, uint32 selection, uint64 ms) const;
@ -2047,11 +2047,11 @@ public:
QString notificationHeader() const; QString notificationHeader() const;
QString notificationText() const; QString notificationText() const;
void updateMedia(const MTPMessageMedia *media, bool allowEmitResize) { void updateMedia(const MTPMessageMedia *media) {
if (media && _media && _media->type() != MediaTypeWebPage) { if (media && _media && _media->type() != MediaTypeWebPage) {
_media->updateFrom(*media, this, allowEmitResize); _media->updateFrom(*media, this);
} else { } else {
setMedia(media, allowEmitResize); setMedia(media);
} }
} }
int32 addToOverview(AddToOverviewMethod method); int32 addToOverview(AddToOverviewMethod method);
@ -2060,7 +2060,7 @@ public:
QString selectedText(uint32 selection) const; QString selectedText(uint32 selection) const;
QString inDialogsText() const; QString inDialogsText() const;
HistoryMedia *getMedia(bool inOverview = false) const; HistoryMedia *getMedia(bool inOverview = false) const;
void setMedia(const MTPMessageMedia *media, bool allowEmitResize); void setMedia(const MTPMessageMedia *media);
void setText(const QString &text, const EntitiesInText &entities); void setText(const QString &text, const EntitiesInText &entities);
QString originalText() const; QString originalText() const;
EntitiesInText originalEntities() const; EntitiesInText originalEntities() const;

View file

@ -4128,12 +4128,11 @@ void MainWidget::feedUpdates(const MTPUpdates &updates, uint64 randomId) {
feedUpdate(MTP_updateMessageID(d.vid, MTP_long(randomId))); // ignore real date feedUpdate(MTP_updateMessageID(d.vid, MTP_long(randomId))); // ignore real date
if (peerId) { if (peerId) {
if (HistoryItem *item = App::histItemById(peerToChannel(peerId), d.vid.v)) { if (HistoryItem *item = App::histItemById(peerToChannel(peerId), d.vid.v)) {
if (!text.isEmpty()) { item->setText(text, d.has_entities() ? entitiesFromMTP(d.ventities.c_vector().v) : EntitiesInText());
item->setText(text, d.has_entities() ? entitiesFromMTP(d.ventities.c_vector().v) : EntitiesInText()); item->updateMedia(d.has_media() ? (&d.vmedia) : 0);
item->initDimensions(); item->initDimensions();
Notify::historyItemResized(item); Notify::historyItemResized(item);
}
item->updateMedia(d.has_media() ? (&d.vmedia) : 0, true);
item->addToOverview(AddToOverviewNew); item->addToOverview(AddToOverviewNew);
} }
} }