mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-23 01:27:15 +02:00
parent
dc631ef631
commit
3d1f21bd05
5 changed files with 61 additions and 22 deletions
|
@ -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";
|
||||
|
|
|
@ -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 QVector<MTPChannelAdminLo
|
|||
}
|
||||
|
||||
auto count = 0;
|
||||
const auto addOne = [&](OwnedItem item) {
|
||||
const auto addOne = [&](OwnedItem item, TimeId sentDate) {
|
||||
if (sentDate) {
|
||||
_itemDates.emplace(item->data(), sentDate);
|
||||
}
|
||||
_eventIds.emplace(id);
|
||||
_itemsByData.emplace(item->data(), item.get());
|
||||
addToItems.push_back(std::move(item));
|
||||
|
|
|
@ -242,6 +242,7 @@ private:
|
|||
std::vector<OwnedItem> _items;
|
||||
std::set<uint64> _eventIds;
|
||||
std::map<not_null<const HistoryItem*>, not_null<Element*>> _itemsByData;
|
||||
base::flat_map<not_null<const HistoryItem*>, TimeId> _itemDates;
|
||||
base::flat_set<FullMsgId> _animatedStickersPlayed;
|
||||
base::flat_map<
|
||||
not_null<PeerData*>,
|
||||
|
|
|
@ -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<HistoryView::ElementDelegate*> delegate,
|
||||
not_null<History*> history,
|
||||
const MTPDchannelAdminLogEvent &event,
|
||||
Fn<void(OwnedItem item)> callback) {
|
||||
Fn<void(OwnedItem item, TimeId sentDate)> 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<HistoryItem*> item) {
|
||||
return callback(OwnedItem(delegate, item));
|
||||
const auto addPart = [&](
|
||||
not_null<HistoryItem*> 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) {
|
||||
|
|
|
@ -22,7 +22,7 @@ void GenerateItems(
|
|||
not_null<HistoryView::ElementDelegate*> delegate,
|
||||
not_null<History*> history,
|
||||
const MTPDchannelAdminLogEvent &event,
|
||||
Fn<void(OwnedItem item)> callback);
|
||||
Fn<void(OwnedItem item, TimeId sentDate)> callback);
|
||||
|
||||
// Smart pointer wrapper for HistoryItem* that destroys the owned item.
|
||||
class OwnedItem {
|
||||
|
|
Loading…
Add table
Reference in a new issue