2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-08-31 14:38:15 +00:00

Track shared media index better.

Fixes #25667.
This commit is contained in:
John Preston
2023-01-09 11:48:33 +04:00
parent 9b74958fab
commit fd47fd4d9e
4 changed files with 27 additions and 6 deletions

View File

@@ -845,18 +845,17 @@ not_null<HistoryItem*> History::addNewToBack(
addItemToBlock(item);
if (!unread && item->isRegular()) {
if (const auto sharedMediaTypes = item->sharedMediaTypes()) {
if (const auto types = item->sharedMediaTypes()) {
auto from = loadedAtTop() ? 0 : minMsgId();
auto till = loadedAtBottom() ? ServerMaxMsgId : maxMsgId();
auto &storage = session().storage();
storage.add(Storage::SharedMediaAddExisting(
peer->id,
MsgId(0), // topicRootId
sharedMediaTypes,
types,
item->id,
{ from, till }));
const auto pinned = sharedMediaTypes.test(
Storage::SharedMediaType::Pinned);
const auto pinned = types.test(Storage::SharedMediaType::Pinned);
if (pinned) {
setHasPinnedMessages(true);
}
@@ -864,7 +863,7 @@ not_null<HistoryItem*> History::addNewToBack(
storage.add(Storage::SharedMediaAddExisting(
peer->id,
topic->rootId(),
sharedMediaTypes,
types,
item->id,
{ item->id, item->id}));
if (pinned) {