mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-01-01 03:22:10 +00:00
Show date from fwdHeader on tooltip
Signed-off-by: Viktor Oreshkin <imselfish@stek29.rocks>
This commit is contained in:
parent
2eff766e88
commit
3f3b9f3608
@ -730,6 +730,7 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
|
||||
"lng_channel_public_link_copied" = "Link copied to clipboard.";
|
||||
|
||||
"lng_forwarded" = "Forwarded from {user}";
|
||||
"lng_forwarded_date" = "Original: {date}";
|
||||
"lng_forwarded_channel" = "Forwarded from {channel}";
|
||||
"lng_forwarded_via" = "Forwarded from {user} via {inline_bot}";
|
||||
"lng_forwarded_channel_via" = "Forwarded from {channel} via {inline_bot}";
|
||||
|
@ -2416,6 +2416,9 @@ QString HistoryInner::tooltipText() const {
|
||||
if (auto edited = App::hoveredItem()->Get<HistoryMessageEdited>()) {
|
||||
dateText += '\n' + lng_edited_date(lt_date, edited->_editDate.toString(QLocale::system().dateTimeFormat(QLocale::LongFormat)));
|
||||
}
|
||||
if (auto forwarded = App::hoveredItem()->Get<HistoryMessageForwarded>()) {
|
||||
dateText += '\n' + lng_forwarded_date(lt_date, forwarded->_originalDate.toString(QLocale::system().dateTimeFormat(QLocale::LongFormat)));
|
||||
}
|
||||
return dateText;
|
||||
}
|
||||
} else if (_dragCursorState == HistoryInForwardedCursorState && _dragAction == NoDrag) {
|
||||
|
@ -136,6 +136,7 @@ struct HistoryMessageEdited : public RuntimeComponent<HistoryMessageEdited> {
|
||||
struct HistoryMessageForwarded : public RuntimeComponent<HistoryMessageForwarded> {
|
||||
void create(const HistoryMessageVia *via) const;
|
||||
|
||||
QDateTime _originalDate;
|
||||
PeerData *_authorOriginal = nullptr;
|
||||
PeerData *_fromOriginal = nullptr;
|
||||
MsgId _originalId = 0;
|
||||
@ -763,6 +764,12 @@ public:
|
||||
return isPost() ? history()->peer : _from;
|
||||
}
|
||||
|
||||
QDateTime dateOriginal() const {
|
||||
if (auto forwarded = Get<HistoryMessageForwarded>()) {
|
||||
return forwarded->_originalDate;
|
||||
}
|
||||
return date;
|
||||
}
|
||||
PeerData *fromOriginal() const {
|
||||
if (auto forwarded = Get<HistoryMessageForwarded>()) {
|
||||
return forwarded->_fromOriginal;
|
||||
|
@ -376,6 +376,7 @@ HistoryMessage::HistoryMessage(History *history, const MTPDmessage &msg)
|
||||
|
||||
if (msg.has_fwd_from() && msg.vfwd_from.type() == mtpc_messageFwdHeader) {
|
||||
auto &f = msg.vfwd_from.c_messageFwdHeader();
|
||||
config.originalDate = ::date(f.vdate);
|
||||
if (f.has_from_id() || f.has_channel_id()) {
|
||||
config.authorIdOriginal = f.has_channel_id() ? peerFromChannel(f.vchannel_id) : peerFromUser(f.vfrom_id);
|
||||
config.fromIdOriginal = f.has_from_id() ? peerFromUser(f.vfrom_id) : peerFromChannel(f.vchannel_id);
|
||||
@ -451,6 +452,7 @@ HistoryMessage::HistoryMessage(History *history, MsgId id, MTPDmessage::Flags fl
|
||||
|
||||
if (fwd->Has<HistoryMessageForwarded>() || !fwd->history()->peer->isSelf()) {
|
||||
// Server doesn't add "fwd_from" to non-forwarded messages from chat with yourself.
|
||||
config.originalDate = fwd->dateOriginal();
|
||||
config.authorIdOriginal = fwd->authorOriginal()->id;
|
||||
config.fromIdOriginal = fwd->fromOriginal()->id;
|
||||
if (fwd->authorOriginal()->isChannel()) {
|
||||
@ -627,6 +629,7 @@ void HistoryMessage::createComponents(const CreateConfig &config) {
|
||||
edited->create(config.editDate, date);
|
||||
}
|
||||
if (auto forwarded = Get<HistoryMessageForwarded>()) {
|
||||
forwarded->_originalDate = config.originalDate;
|
||||
forwarded->_authorOriginal = App::peer(config.authorIdOriginal);
|
||||
forwarded->_fromOriginal = App::peer(config.fromIdOriginal);
|
||||
forwarded->_originalId = config.originalId;
|
||||
|
@ -205,6 +205,7 @@ private:
|
||||
PeerId authorIdOriginal = 0;
|
||||
PeerId fromIdOriginal = 0;
|
||||
MsgId originalId = 0;
|
||||
QDateTime originalDate;
|
||||
QDateTime editDate;
|
||||
|
||||
// For messages created from MTP structs.
|
||||
|
Loading…
Reference in New Issue
Block a user