mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-03-31 15:59:54 +00:00
Fix timestamp highlights when editing media.
This commit is contained in:
parent
1ba052cc13
commit
fedf29adb1
@ -1681,6 +1681,7 @@ bool Session::checkEntitiesAndViewsUpdate(const MTPDmessage &data) {
|
||||
existing->indexAsNewItem();
|
||||
existing->contributeToSlowmode(data.vdate().v);
|
||||
requestItemTextRefresh(existing);
|
||||
updateDependentMessages(existing);
|
||||
if (existing->mainView()) {
|
||||
checkSavedGif(existing);
|
||||
return true;
|
||||
|
@ -23,6 +23,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include "data/data_session.h"
|
||||
#include "data/data_user.h"
|
||||
#include "data/data_file_origin.h"
|
||||
#include "data/data_document.h"
|
||||
#include "main/main_session.h"
|
||||
#include "window/window_session_controller.h"
|
||||
#include "facades.h"
|
||||
@ -179,6 +180,7 @@ void HistoryMessageForwarded::create(const HistoryMessageVia *via) const {
|
||||
bool HistoryMessageReply::updateData(
|
||||
not_null<HistoryMessage*> holder,
|
||||
bool force) {
|
||||
const auto guard = gsl::finally([&] { refreshReplyToDocument(); });
|
||||
if (!force) {
|
||||
if (replyToMsg || !replyToMsgId) {
|
||||
return true;
|
||||
@ -358,11 +360,13 @@ void HistoryMessageReply::paint(
|
||||
}
|
||||
}
|
||||
|
||||
DocumentData *HistoryMessageReply::replyToDocument() const {
|
||||
void HistoryMessageReply::refreshReplyToDocument() {
|
||||
replyToDocumentId = 0;
|
||||
if (const auto media = replyToMsg ? replyToMsg->media() : nullptr) {
|
||||
return media->document();
|
||||
if (const auto document = media->document()) {
|
||||
replyToDocumentId = document->id;
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
ReplyMarkupClickHandler::ReplyMarkupClickHandler(
|
||||
|
@ -142,10 +142,11 @@ struct HistoryMessageReply : public RuntimeComponent<HistoryMessageReply, Histor
|
||||
void setReplyToLinkFrom(
|
||||
not_null<HistoryMessage*> holder);
|
||||
|
||||
[[nodiscard]] DocumentData *replyToDocument() const;
|
||||
[[nodiscard]] void refreshReplyToDocument();
|
||||
|
||||
MsgId replyToMsgId = 0;
|
||||
HistoryItem *replyToMsg = nullptr;
|
||||
DocumentId replyToDocumentId = 0;
|
||||
ClickHandlerPtr replyToLnk;
|
||||
mutable Ui::Text::String replyToName, replyToText;
|
||||
mutable int replyToVersion = 0;
|
||||
|
@ -699,9 +699,9 @@ int HistoryMessage::viewsCount() const {
|
||||
|
||||
bool HistoryMessage::updateDependencyItem() {
|
||||
if (const auto reply = Get<HistoryMessageReply>()) {
|
||||
const auto document = reply->replyToDocument();
|
||||
const auto documentId = reply->replyToDocumentId;
|
||||
const auto result = reply->updateData(this, true);
|
||||
if (document != reply->replyToDocument()
|
||||
if (documentId != reply->replyToDocumentId
|
||||
&& generateLocalEntitiesByReply()) {
|
||||
reapplyText();
|
||||
}
|
||||
@ -902,6 +902,7 @@ void HistoryMessage::returnSavedMedia() {
|
||||
history()->owner().groups().refreshMessage(this, true);
|
||||
} else {
|
||||
history()->owner().requestItemViewRefresh(this);
|
||||
history()->owner().updateDependentMessages(this);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1167,21 +1168,22 @@ TextWithEntities HistoryMessage::withLocalEntities(
|
||||
return textWithEntities;
|
||||
}
|
||||
if (const auto reply = Get<HistoryMessageReply>()) {
|
||||
if (const auto document = reply->replyToDocument()) {
|
||||
if (document->isVideoFile() || document->isSong()) {
|
||||
using namespace HistoryView;
|
||||
const auto duration = document->getDuration();
|
||||
const auto base = (duration > 0)
|
||||
? DocumentTimestampLinkBase(
|
||||
document,
|
||||
reply->replyToMsg->fullId())
|
||||
: QString();
|
||||
if (!base.isEmpty()) {
|
||||
return AddTimestampLinks(
|
||||
textWithEntities,
|
||||
duration,
|
||||
base);
|
||||
}
|
||||
const auto document = reply->replyToDocumentId
|
||||
? history()->owner().document(reply->replyToDocumentId).get()
|
||||
: nullptr;
|
||||
if (document && (document->isVideoFile() || document->isSong())) {
|
||||
using namespace HistoryView;
|
||||
const auto duration = document->getDuration();
|
||||
const auto base = (duration > 0)
|
||||
? DocumentTimestampLinkBase(
|
||||
document,
|
||||
reply->replyToMsg->fullId())
|
||||
: QString();
|
||||
if (!base.isEmpty()) {
|
||||
return AddTimestampLinks(
|
||||
textWithEntities,
|
||||
duration,
|
||||
base);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1353,9 +1355,9 @@ void HistoryMessage::setRealId(MsgId newId) {
|
||||
|
||||
void HistoryMessage::dependencyItemRemoved(HistoryItem *dependency) {
|
||||
if (const auto reply = Get<HistoryMessageReply>()) {
|
||||
const auto document = reply->replyToDocument();
|
||||
const auto documentId = reply->replyToDocumentId;
|
||||
reply->itemRemoved(this, dependency);
|
||||
if (document != reply->replyToDocument()
|
||||
if (documentId != reply->replyToDocumentId
|
||||
&& generateLocalEntitiesByReply()) {
|
||||
reapplyText();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user