From 5a75dd2b6f52fb027f91d0a82d69c10f595f7bd9 Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Sat, 9 May 2020 23:34:57 +0300 Subject: [PATCH] Added handling of updates for rescheduled messages. --- Telegram/SourceFiles/data/data_scheduled_messages.cpp | 1 + Telegram/SourceFiles/history/history_item.cpp | 11 +++++++++++ Telegram/SourceFiles/history/history_item.h | 3 +++ 3 files changed, 15 insertions(+) diff --git a/Telegram/SourceFiles/data/data_scheduled_messages.cpp b/Telegram/SourceFiles/data/data_scheduled_messages.cpp index 8d6831675..75b725b3e 100644 --- a/Telegram/SourceFiles/data/data_scheduled_messages.cpp +++ b/Telegram/SourceFiles/data/data_scheduled_messages.cpp @@ -414,6 +414,7 @@ HistoryItem *ScheduledMessages::append( }, data.vmedia()); existing->updateReplyMarkup(data.vreply_markup()); existing->updateForwardedInfo(data.vfwd_from()); + existing->updateDate(data.vdate().v); history->owner().requestItemTextRefresh(existing); }, [&](const auto &data) {}); return existing; diff --git a/Telegram/SourceFiles/history/history_item.cpp b/Telegram/SourceFiles/history/history_item.cpp index f515c4891..20f40fc25 100644 --- a/Telegram/SourceFiles/history/history_item.cpp +++ b/Telegram/SourceFiles/history/history_item.cpp @@ -708,6 +708,17 @@ MsgId HistoryItem::idOriginal() const { return id; } +void HistoryItem::updateDate(TimeId newDate) { + if (canUpdateDate() && _date != newDate) { + _date = newDate; + _history->owner().requestItemViewRefresh(this); + } +} + +bool HistoryItem::canUpdateDate() const { + return isScheduled(); +} + void HistoryItem::sendFailed() { Expects(_clientFlags & MTPDmessage_ClientFlag::f_sending); Expects(!(_clientFlags & MTPDmessage_ClientFlag::f_failed)); diff --git a/Telegram/SourceFiles/history/history_item.h b/Telegram/SourceFiles/history/history_item.h index 92f149492..20ec30e1e 100644 --- a/Telegram/SourceFiles/history/history_item.h +++ b/Telegram/SourceFiles/history/history_item.h @@ -328,6 +328,9 @@ public: [[nodiscard]] virtual std::unique_ptr createView( not_null delegate) = 0; + void updateDate(TimeId newDate); + [[nodiscard]] bool canUpdateDate() const; + virtual ~HistoryItem(); MsgId id;