Don't show time for service messages with additional data
This commit is contained in:
parent
22f2fa2f19
commit
c528820713
4 changed files with 30 additions and 12 deletions
|
|
@ -32,7 +32,11 @@ constexpr auto kMessagesPerPage = 50;
|
|||
history->session().data().nextNonHistoryEntryId(),
|
||||
MTPDmessage_ClientFlag::f_fake_history_item,
|
||||
date,
|
||||
HistoryService::PreparedText{ text });
|
||||
HistoryService::PreparedText{ text },
|
||||
MTPDmessage::Flags(0),
|
||||
PeerId(0),
|
||||
nullptr,
|
||||
false);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
|
@ -237,6 +241,7 @@ void RepliesList::injectRootDivider(
|
|||
text());
|
||||
} else if (_dividerWithComments != withComments) {
|
||||
_dividerWithComments = withComments;
|
||||
_divider->setNeedTime(false);
|
||||
_divider->setServiceText(HistoryService::PreparedText{ text() });
|
||||
}
|
||||
slice->ids.push_back(_divider->fullId());
|
||||
|
|
|
|||
|
|
@ -398,7 +398,7 @@ void GenerateItems(
|
|||
const auto fromLink = from->createOpenLink();
|
||||
const auto fromLinkText = textcmdLink(1, fromName);
|
||||
|
||||
auto addSimpleServiceMessage = [&](const QString &text, PhotoData *photo = nullptr) {
|
||||
auto addSimpleServiceMessage = [&](const QString &text, PhotoData *photo = nullptr, bool showTime = true) {
|
||||
auto message = HistoryService::PreparedText { text };
|
||||
message.links.push_back(fromLink);
|
||||
addPart(history->makeServiceMessage(
|
||||
|
|
@ -408,7 +408,8 @@ void GenerateItems(
|
|||
message,
|
||||
MTPDmessage::Flags(0),
|
||||
peerToUser(from->id),
|
||||
photo));
|
||||
photo,
|
||||
showTime));
|
||||
};
|
||||
|
||||
auto createChangeTitle = [&](const MTPDchannelAdminLogEventActionChangeTitle &action) {
|
||||
|
|
@ -434,7 +435,7 @@ void GenerateItems(
|
|||
? tr::lng_admin_log_removed_description_channel
|
||||
: tr::lng_admin_log_changed_description_channel)
|
||||
)(tr::now, lt_from, fromLinkText);
|
||||
addSimpleServiceMessage(text);
|
||||
addSimpleServiceMessage(text, nullptr, false);
|
||||
|
||||
auto bodyFlags = Flag::f_entities | Flag::f_from_id;
|
||||
auto bodyClientFlags = MTPDmessage_ClientFlag::f_admin_log_entry;
|
||||
|
|
@ -469,7 +470,7 @@ void GenerateItems(
|
|||
? tr::lng_admin_log_removed_link_channel
|
||||
: tr::lng_admin_log_changed_link_channel)
|
||||
)(tr::now, lt_from, fromLinkText);
|
||||
addSimpleServiceMessage(text);
|
||||
addSimpleServiceMessage(text, nullptr, false);
|
||||
|
||||
auto bodyFlags = Flag::f_entities | Flag::f_from_id;
|
||||
auto bodyClientFlags = MTPDmessage_ClientFlag::f_admin_log_entry;
|
||||
|
|
@ -542,7 +543,7 @@ void GenerateItems(
|
|||
auto text = (pinned
|
||||
? tr::lng_admin_log_pinned_message
|
||||
: tr::lng_admin_log_unpinned_message)(tr::now, lt_from, fromLinkText);
|
||||
addSimpleServiceMessage(text);
|
||||
addSimpleServiceMessage(text, nullptr, false);
|
||||
|
||||
auto detachExistingItem = false;
|
||||
addPart(history->createItem(
|
||||
|
|
@ -569,7 +570,7 @@ void GenerateItems(
|
|||
tr::now,
|
||||
lt_from,
|
||||
fromLinkText);
|
||||
addSimpleServiceMessage(text);
|
||||
addSimpleServiceMessage(text, nullptr, false);
|
||||
|
||||
auto oldValue = ExtractEditedText(session, action.vprev_message());
|
||||
auto detachExistingItem = false;
|
||||
|
|
@ -595,7 +596,7 @@ void GenerateItems(
|
|||
|
||||
auto createDeleteMessage = [&](const MTPDchannelAdminLogEventActionDeleteMessage &action) {
|
||||
auto text = tr::lng_admin_log_deleted_message(tr::now, lt_from, fromLinkText);
|
||||
addSimpleServiceMessage(text);
|
||||
addSimpleServiceMessage(text, nullptr, false);
|
||||
|
||||
auto detachExistingItem = false;
|
||||
addPart(history->createItem(
|
||||
|
|
@ -737,7 +738,7 @@ void GenerateItems(
|
|||
|
||||
auto createStopPoll = [&](const MTPDchannelAdminLogEventActionStopPoll &action) {
|
||||
auto text = tr::lng_admin_log_stopped_poll(tr::now, lt_from, fromLinkText);
|
||||
addSimpleServiceMessage(text);
|
||||
addSimpleServiceMessage(text, nullptr, false);
|
||||
|
||||
auto detachExistingItem = false;
|
||||
addPart(history->createItem(
|
||||
|
|
|
|||
|
|
@ -115,6 +115,7 @@ QString GenerateServiceTime(TimeId date) {
|
|||
} // namespace
|
||||
|
||||
void HistoryService::setMessageByAction(const MTPmessageAction &action) {
|
||||
setNeedTime(true);
|
||||
auto prepareChatAddUserText = [this](const MTPDmessageActionChatAddUser &action) {
|
||||
auto result = PreparedText{};
|
||||
auto &users = action.vusers().v;
|
||||
|
|
@ -781,8 +782,10 @@ HistoryService::HistoryService(
|
|||
const PreparedText &message,
|
||||
MTPDmessage::Flags flags,
|
||||
PeerId from,
|
||||
PhotoData *photo)
|
||||
PhotoData *photo,
|
||||
bool showTime)
|
||||
: HistoryItem(history, id, flags, clientFlags, date, from) {
|
||||
setNeedTime(showTime);
|
||||
setServiceText(message);
|
||||
if (photo) {
|
||||
_media = std::make_unique<Data::MediaPhoto>(
|
||||
|
|
@ -837,7 +840,7 @@ void HistoryService::setServiceText(const PreparedText &prepared) {
|
|||
Ui::ItemTextServiceOptions());
|
||||
_postfixedText.setText(
|
||||
st::serviceTextStyle,
|
||||
prepared.text + GenerateServiceTime(date()),
|
||||
(needTime() ? prepared.text + GenerateServiceTime(date()) : prepared.text),
|
||||
Ui::ItemTextServiceOptions());
|
||||
auto linkIndex = 0;
|
||||
for_const (auto &link, prepared.links) {
|
||||
|
|
|
|||
|
|
@ -80,7 +80,8 @@ public:
|
|||
const PreparedText &message,
|
||||
MTPDmessage::Flags flags = 0,
|
||||
PeerId from = 0,
|
||||
PhotoData *photo = nullptr);
|
||||
PhotoData *photo = nullptr,
|
||||
bool showTime = true);
|
||||
|
||||
bool updateDependencyItem() override;
|
||||
MsgId dependencyMsgId() const override {
|
||||
|
|
@ -113,6 +114,13 @@ public:
|
|||
HistoryView::Element *replacing = nullptr) override;
|
||||
|
||||
void setServiceText(const PreparedText &prepared);
|
||||
void setNeedTime(bool need) {
|
||||
_needTime = need;
|
||||
};
|
||||
|
||||
bool needTime() {
|
||||
return _needTime;
|
||||
};
|
||||
|
||||
~HistoryService();
|
||||
|
||||
|
|
@ -165,6 +173,7 @@ private:
|
|||
friend class HistoryView::Service;
|
||||
|
||||
Ui::Text::String _postfixedText;
|
||||
bool _needTime = true;
|
||||
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue