mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-15 21:57:10 +02:00
Fix pinning between topics.
This commit is contained in:
parent
9a54473e03
commit
0737034ea6
3 changed files with 13 additions and 4 deletions
|
@ -741,6 +741,7 @@ void HistoryItem::indexAsNewItem() {
|
|||
if (const auto types = sharedMediaTypes()) {
|
||||
_history->session().storage().add(Storage::SharedMediaAddNew(
|
||||
_history->peer->id,
|
||||
topicRootId(),
|
||||
types,
|
||||
id));
|
||||
if (types.test(Storage::SharedMediaType::Pinned)) {
|
||||
|
|
|
@ -35,15 +35,20 @@ auto SharedMedia::enforceLists(Key key)
|
|||
}
|
||||
|
||||
void SharedMedia::add(SharedMediaAddNew &&query) {
|
||||
auto peerIt = enforceLists({ query.peerId, MsgId(0) });
|
||||
while (peerIt != end(_lists) && peerIt->first.peerId == query.peerId) {
|
||||
const auto addByIt = [&](const auto i) {
|
||||
for (auto index = 0; index != kSharedMediaTypeCount; ++index) {
|
||||
auto type = static_cast<SharedMediaType>(index);
|
||||
if (query.types.test(type)) {
|
||||
peerIt->second[index].addNew(query.messageId);
|
||||
i->second[index].addNew(query.messageId);
|
||||
}
|
||||
}
|
||||
++peerIt;
|
||||
};
|
||||
addByIt(enforceLists({ query.peerId, MsgId(0) }));
|
||||
const auto topicIt = query.topicRootId
|
||||
? _lists.find({ query.peerId, query.topicRootId })
|
||||
: end(_lists);
|
||||
if (topicIt != end(_lists)) {
|
||||
addByIt(topicIt);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -41,14 +41,17 @@ using SharedMediaTypesMask = base::enum_mask<SharedMediaType>;
|
|||
struct SharedMediaAddNew {
|
||||
SharedMediaAddNew(
|
||||
PeerId peerId,
|
||||
MsgId topicRootId,
|
||||
SharedMediaTypesMask types,
|
||||
MsgId messageId)
|
||||
: peerId(peerId)
|
||||
, topicRootId(topicRootId)
|
||||
, messageId(messageId)
|
||||
, types(types) {
|
||||
}
|
||||
|
||||
PeerId peerId = 0;
|
||||
MsgId topicRootId = 0;
|
||||
MsgId messageId = 0;
|
||||
SharedMediaTypesMask types;
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue