diff --git a/Telegram/Resources/langs/lang.strings b/Telegram/Resources/langs/lang.strings index 5efaea8d4..dcfb9aead 100644 --- a/Telegram/Resources/langs/lang.strings +++ b/Telegram/Resources/langs/lang.strings @@ -1187,6 +1187,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL "lng_in_reply_to" = "In reply to"; "lng_edited" = "edited"; "lng_edited_date" = "Edited: {date}"; +"lng_sent_date" = "Sent: {date}"; "lng_admin_badge" = "admin"; "lng_owner_badge" = "owner"; "lng_channel_badge" = "channel"; diff --git a/Telegram/SourceFiles/history/admin_log/history_admin_log_inner.cpp b/Telegram/SourceFiles/history/admin_log/history_admin_log_inner.cpp index f96a4e476..1fea6e2da 100644 --- a/Telegram/SourceFiles/history/admin_log/history_admin_log_inner.cpp +++ b/Telegram/SourceFiles/history/admin_log/history_admin_log_inner.cpp @@ -21,6 +21,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "chat_helpers/message_field.h" #include "boxes/sticker_set_box.h" #include "base/platform/base_platform_info.h" +#include "base/unixtime.h" #include "mainwindow.h" #include "mainwidget.h" #include "core/application.h" @@ -509,8 +510,17 @@ QString InnerWidget::tooltipText() const { if (_mouseCursorState == CursorState::Date && _mouseAction == MouseAction::None) { if (const auto view = App::hoveredItem()) { - auto dateText = view->dateTime().toString( - QLocale::system().dateTimeFormat(QLocale::LongFormat)); + const auto format = QLocale::system().dateTimeFormat( + QLocale::LongFormat); + auto dateText = view->dateTime().toString(format); + + const auto sentIt = _itemDates.find(view->data()); + if (sentIt != end(_itemDates)) { + dateText += '\n' + tr::lng_sent_date( + tr::now, + lt_date, + base::unixtime::parse(sentIt->second).toString(format)); + } return dateText; } } else if (_mouseCursorState == CursorState::Forwarded @@ -722,7 +732,10 @@ void InnerWidget::addEvents(Direction direction, const QVectordata(), sentDate); + } _eventIds.emplace(id); _itemsByData.emplace(item->data(), item.get()); addToItems.push_back(std::move(item)); diff --git a/Telegram/SourceFiles/history/admin_log/history_admin_log_inner.h b/Telegram/SourceFiles/history/admin_log/history_admin_log_inner.h index ca8e50066..b3af9bb0b 100644 --- a/Telegram/SourceFiles/history/admin_log/history_admin_log_inner.h +++ b/Telegram/SourceFiles/history/admin_log/history_admin_log_inner.h @@ -242,6 +242,7 @@ private: std::vector _items; std::set _eventIds; std::map, not_null> _itemsByData; + base::flat_map, TimeId> _itemDates; base::flat_set _animatedStickersPlayed; base::flat_map< not_null, diff --git a/Telegram/SourceFiles/history/admin_log/history_admin_log_item.cpp b/Telegram/SourceFiles/history/admin_log/history_admin_log_item.cpp index d5647de4b..ed06eda57 100644 --- a/Telegram/SourceFiles/history/admin_log/history_admin_log_item.cpp +++ b/Telegram/SourceFiles/history/admin_log/history_admin_log_item.cpp @@ -45,6 +45,16 @@ TextWithEntities PrepareText(const QString &value, const QString &emptyValue) { return result; } +TimeId ExtractSentDate(const MTPMessage &message) { + return message.match([&](const MTPDmessageEmpty &) { + return 0; + }, [&](const MTPDmessageService &data) { + return data.vdate().v; + }, [&](const MTPDmessage &data) { + return data.vdate().v; + }); +} + MTPMessage PrepareLogMessage( const MTPMessage &message, MsgId newId, @@ -380,7 +390,7 @@ void GenerateItems( not_null delegate, not_null history, const MTPDchannelAdminLogEvent &event, - Fn callback) { + Fn callback) { Expects(history->peer->isChannel()); const auto session = &history->session(); @@ -389,8 +399,10 @@ void GenerateItems( const auto channel = history->peer->asChannel(); const auto &action = event.vaction(); const auto date = event.vdate().v; - const auto addPart = [&](not_null item) { - return callback(OwnedItem(delegate, item)); + const auto addPart = [&]( + not_null item, + TimeId sentDate = 0) { + return callback(OwnedItem(delegate, item), sentDate); }; using Flag = MTPDmessage::Flag; @@ -545,13 +557,15 @@ void GenerateItems( addSimpleServiceMessage(text); auto detachExistingItem = false; - addPart(history->createItem( - PrepareLogMessage( - action.vmessage(), - history->nextNonHistoryEntryId(), - date), - MTPDmessage_ClientFlag::f_admin_log_entry, - detachExistingItem)); + addPart( + history->createItem( + PrepareLogMessage( + action.vmessage(), + history->nextNonHistoryEntryId(), + date), + MTPDmessage_ClientFlag::f_admin_log_entry, + detachExistingItem), + ExtractSentDate(action.vmessage())); }, [&](const auto &) { auto text = tr::lng_admin_log_unpinned_message(tr::now, lt_from, fromLinkText); addSimpleServiceMessage(text); @@ -598,10 +612,15 @@ void GenerateItems( addSimpleServiceMessage(text); auto detachExistingItem = false; - addPart(history->createItem( - PrepareLogMessage(action.vmessage(), history->nextNonHistoryEntryId(), date), - MTPDmessage_ClientFlag::f_admin_log_entry, - detachExistingItem)); + addPart( + history->createItem( + PrepareLogMessage( + action.vmessage(), + history->nextNonHistoryEntryId(), + date), + MTPDmessage_ClientFlag::f_admin_log_entry, + detachExistingItem), + ExtractSentDate(action.vmessage())); }; auto createParticipantJoin = [&]() { @@ -740,10 +759,15 @@ void GenerateItems( addSimpleServiceMessage(text); auto detachExistingItem = false; - addPart(history->createItem( - PrepareLogMessage(action.vmessage(), history->nextNonHistoryEntryId(), date), - MTPDmessage_ClientFlag::f_admin_log_entry, - detachExistingItem)); + addPart( + history->createItem( + PrepareLogMessage( + action.vmessage(), + history->nextNonHistoryEntryId(), + date), + MTPDmessage_ClientFlag::f_admin_log_entry, + detachExistingItem), + ExtractSentDate(action.vmessage())); }; auto createChangeLinkedChat = [&](const MTPDchannelAdminLogEventActionChangeLinkedChat &action) { diff --git a/Telegram/SourceFiles/history/admin_log/history_admin_log_item.h b/Telegram/SourceFiles/history/admin_log/history_admin_log_item.h index fa0373780..ceaa50bc3 100644 --- a/Telegram/SourceFiles/history/admin_log/history_admin_log_item.h +++ b/Telegram/SourceFiles/history/admin_log/history_admin_log_item.h @@ -22,7 +22,7 @@ void GenerateItems( not_null delegate, not_null history, const MTPDchannelAdminLogEvent &event, - Fn callback); + Fn callback); // Smart pointer wrapper for HistoryItem* that destroys the owned item. class OwnedItem {