Empty messages do not participate in displayDate() flow.

Example of an empty message is service message after clear history.
This commit is contained in:
John Preston 2016-06-08 22:14:17 +03:00
parent 23a598ba3d
commit a5cbbba12d
5 changed files with 12 additions and 8 deletions

View File

@ -107,7 +107,7 @@ void paintRow(Painter &p, History *history, HistoryItem *item, HistoryDraft *dra
} else {
history->typingText.drawElided(p, nameleft, texttop, namewidth);
}
} else {
} else if (!item->isEmpty()) {
paintRowDate(p, item->date, rectForName, active);
// draw check

View File

@ -2838,6 +2838,15 @@ void HistoryItem::clipCallback(ClipReaderNotification notification) {
}
}
bool HistoryItem::displayDate() const {
if (isEmpty()) return false;
if (auto prev = previous()) {
return prev->isEmpty() || (prev->date.date() != date.date());
}
return true;
}
HistoryItem::~HistoryItem() {
App::historyUnregItem(this);
if (id < 0 && App::uploader()) {

View File

@ -1488,12 +1488,7 @@ protected:
// this should be used only in previousItemChanged()
// to add required bits to the Composer mask
// after that always use Has<HistoryMessageDate>()
bool displayDate() const {
if (auto prev = previous()) {
return prev->date.date() != date.date();
}
return true;
}
bool displayDate() const;
// this should be used only in previousItemChanged() or when
// HistoryMessageDate or HistoryMessageUnreadBar bit is changed in the Composer mask

View File

@ -821,7 +821,6 @@ void MainWidget::clearHistory(PeerData *peer) {
h->clear();
h->newLoaded = h->oldLoaded = true;
}
Ui::showPeerHistory(peer->id, ShowAtUnreadMsgId);
MTPmessages_DeleteHistory::Flags flags = MTPmessages_DeleteHistory::Flag::f_just_clear;
DeleteHistoryRequest request = { peer, true };
MTP::send(MTPmessages_DeleteHistory(MTP_flags(flags), peer->input, MTP_int(0)), rpcDone(&MainWidget::deleteHistoryPart, request));

View File

@ -280,6 +280,7 @@ void ActionsWidget::onClearHistory() {
void ActionsWidget::onClearHistorySure() {
Ui::hideLayer();
App::main()->clearHistory(peer());
Ui::showPeerHistory(peer(), ShowAtUnreadMsgId);
}
void ActionsWidget::onDeleteConversation() {