Improved processing of out expired voice messages.

This commit is contained in:
23rd 2023-12-29 09:29:12 +03:00 committed by John Preston
parent 85286684e3
commit a1c7a48958
3 changed files with 34 additions and 5 deletions

View file

@ -44,6 +44,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "lang/lang_cloud_manager.h"
#include "history/history.h"
#include "history/history_item.h"
#include "history/history_item_helpers.h"
#include "history/history_unread_things.h"
#include "core/application.h"
#include "storage/storage_account.h"
@ -1204,11 +1205,12 @@ void Updates::applyUpdateNoPtsCheck(const MTPUpdate &update) {
item->markMediaAndMentionRead();
_session->data().requestItemRepaint(item);
if (item->out()
&& item->history()->peer->isUser()
&& !requestingDifference()) {
item->history()->peer->asUser()->madeAction(
base::unixtime::now());
if (item->out()) {
const auto user = item->history()->peer->asUser();
if (user && !requestingDifference()) {
user->madeAction(base::unixtime::now());
}
ClearMediaAsExpired(item);
}
}
} else {

View file

@ -14,6 +14,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "data/data_channel.h"
#include "data/data_chat.h"
#include "data/data_changes.h"
#include "data/data_document.h"
#include "data/data_group_call.h"
#include "data/data_forum.h"
#include "data/data_forum_topic.h"
@ -783,3 +784,27 @@ void ShowTrialTranscribesToast(int left, TimeId until) {
.filter = filter,
});
}
void ClearMediaAsExpired(not_null<HistoryItem*> item) {
if (const auto media = item->media()) {
if (!media->ttlSeconds()) {
return;
}
if (const auto document = media->document()) {
item->applyEditionToHistoryCleared();
auto text = (document->isVideoFile()
? tr::lng_ttl_video_expired
: document->isVoiceMessage()
? tr::lng_ttl_voice_expired
: document->isVideoMessage()
? tr::lng_ttl_round_expired
: tr::lng_message_empty)(tr::now, Ui::Text::WithEntities);
item->updateServiceText(PreparedServiceText{ std::move(text) });
} else if (const auto photo = media->photo()) {
item->applyEditionToHistoryCleared();
item->updateServiceText(PreparedServiceText{
tr::lng_ttl_photo_expired(tr::now, Ui::Text::WithEntities)
});
}
}
}

View file

@ -156,3 +156,5 @@ ClickHandlerPtr JumpToStoryClickHandler(
CallId callId);
void ShowTrialTranscribesToast(int left, TimeId until);
void ClearMediaAsExpired(not_null<HistoryItem*> item);