Fix pinning between topics.
This commit is contained in:
parent
9a54473e03
commit
0737034ea6
|
@ -741,6 +741,7 @@ void HistoryItem::indexAsNewItem() {
|
||||||
if (const auto types = sharedMediaTypes()) {
|
if (const auto types = sharedMediaTypes()) {
|
||||||
_history->session().storage().add(Storage::SharedMediaAddNew(
|
_history->session().storage().add(Storage::SharedMediaAddNew(
|
||||||
_history->peer->id,
|
_history->peer->id,
|
||||||
|
topicRootId(),
|
||||||
types,
|
types,
|
||||||
id));
|
id));
|
||||||
if (types.test(Storage::SharedMediaType::Pinned)) {
|
if (types.test(Storage::SharedMediaType::Pinned)) {
|
||||||
|
|
|
@ -35,15 +35,20 @@ auto SharedMedia::enforceLists(Key key)
|
||||||
}
|
}
|
||||||
|
|
||||||
void SharedMedia::add(SharedMediaAddNew &&query) {
|
void SharedMedia::add(SharedMediaAddNew &&query) {
|
||||||
auto peerIt = enforceLists({ query.peerId, MsgId(0) });
|
const auto addByIt = [&](const auto i) {
|
||||||
while (peerIt != end(_lists) && peerIt->first.peerId == query.peerId) {
|
|
||||||
for (auto index = 0; index != kSharedMediaTypeCount; ++index) {
|
for (auto index = 0; index != kSharedMediaTypeCount; ++index) {
|
||||||
auto type = static_cast<SharedMediaType>(index);
|
auto type = static_cast<SharedMediaType>(index);
|
||||||
if (query.types.test(type)) {
|
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 {
|
struct SharedMediaAddNew {
|
||||||
SharedMediaAddNew(
|
SharedMediaAddNew(
|
||||||
PeerId peerId,
|
PeerId peerId,
|
||||||
|
MsgId topicRootId,
|
||||||
SharedMediaTypesMask types,
|
SharedMediaTypesMask types,
|
||||||
MsgId messageId)
|
MsgId messageId)
|
||||||
: peerId(peerId)
|
: peerId(peerId)
|
||||||
|
, topicRootId(topicRootId)
|
||||||
, messageId(messageId)
|
, messageId(messageId)
|
||||||
, types(types) {
|
, types(types) {
|
||||||
}
|
}
|
||||||
|
|
||||||
PeerId peerId = 0;
|
PeerId peerId = 0;
|
||||||
|
MsgId topicRootId = 0;
|
||||||
MsgId messageId = 0;
|
MsgId messageId = 0;
|
||||||
SharedMediaTypesMask types;
|
SharedMediaTypesMask types;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue