From 021a5881c2d13b7a62e3469b0fa7b68b782ef92e Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Sat, 23 Nov 2024 14:10:04 +0300 Subject: [PATCH] Improved display of history begin for channels with enabled auto-delete. --- Telegram/SourceFiles/data/data_types.cpp | 4 ++-- Telegram/SourceFiles/history/history.cpp | 9 ++++++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/Telegram/SourceFiles/data/data_types.cpp b/Telegram/SourceFiles/data/data_types.cpp index ab792cd3052991..8fed3ecd301e1e 100644 --- a/Telegram/SourceFiles/data/data_types.cpp +++ b/Telegram/SourceFiles/data/data_types.cpp @@ -114,8 +114,8 @@ void MessageCursor::applyTo(not_null field) { } PeerId PeerFromMessage(const MTPmessage &message) { - return message.match([](const MTPDmessageEmpty &) { - return PeerId(0); + return message.match([](const MTPDmessageEmpty &data) { + return data.vpeer_id() ? peerFromMTP(*data.vpeer_id()) : PeerId(0); }, [](const auto &data) { return peerFromMTP(data.vpeer_id()); }); diff --git a/Telegram/SourceFiles/history/history.cpp b/Telegram/SourceFiles/history/history.cpp index 250fcb83131fde..56ca12032642b2 100644 --- a/Telegram/SourceFiles/history/history.cpp +++ b/Telegram/SourceFiles/history/history.cpp @@ -459,8 +459,15 @@ std::vector> History::createItems( const auto detachExistingItem = true; for (auto i = data.cend(), e = data.cbegin(); i != e;) { const auto &data = *--i; + const auto id = IdFromMessage(data); + if ((id.bare == 1) && (data.type() == mtpc_messageEmpty)) { + // The first message of channels should be a service message + // about its creation. But if channel auto-cleaning is enabled, + // the first message comes empty and is displayed incorrectly. + continue; + } result.emplace_back(createItem( - IdFromMessage(data), + id, data, localFlags, detachExistingItem));