Added ability to validate playlists in section of scheduled messages.

This commit is contained in:
23rd 2021-06-29 19:33:30 +03:00
parent 1a93f4fa4c
commit 4753a57091

View file

@ -269,7 +269,8 @@ bool Instance::validPlaylist(not_null<Data*> data) {
using Key = SliceKey; using Key = SliceKey;
const auto inSameDomain = [](const Key &a, const Key &b) { const auto inSameDomain = [](const Key &a, const Key &b) {
return (a.peerId == b.peerId) return (a.peerId == b.peerId)
&& (a.migratedPeerId == b.migratedPeerId); && (a.migratedPeerId == b.migratedPeerId)
&& (a.scheduled == b.scheduled);
}; };
const auto countDistanceInData = [&](const Key &a, const Key &b) { const auto countDistanceInData = [&](const Key &a, const Key &b) {
return [&](const SparseIdsMergedSlice &data) { return [&](const SparseIdsMergedSlice &data) {
@ -300,7 +301,11 @@ void Instance::validatePlaylist(not_null<Data*> data) {
data->playlistLifetime.destroy(); data->playlistLifetime.destroy();
if (const auto key = playlistKey(data)) { if (const auto key = playlistKey(data)) {
data->playlistRequestedKey = key; data->playlistRequestedKey = key;
SharedMediaMergedViewer(
const auto sharedMediaViewer = key->scheduled
? SharedScheduledMediaViewer
: SharedMediaMergedViewer;
sharedMediaViewer(
&data->history->session(), &data->history->session(),
SharedMediaMergedKey(*key, data->overview), SharedMediaMergedKey(*key, data->overview),
kIdsLimit, kIdsLimit,
@ -321,7 +326,11 @@ auto Instance::playlistKey(not_null<Data*> data) const
-> std::optional<SliceKey> { -> std::optional<SliceKey> {
const auto contextId = data->current.contextId(); const auto contextId = data->current.contextId();
const auto history = data->history; const auto history = data->history;
if (!contextId || !history || !IsServerMsgId(contextId.msg)) { if (!contextId || !history) {
return {};
}
const auto item = data->history->owner().message(contextId);
if (!item || (!IsServerMsgId(contextId.msg) && !item->isScheduled())) {
return {}; return {};
} }
@ -331,7 +340,8 @@ auto Instance::playlistKey(not_null<Data*> data) const
return SliceKey( return SliceKey(
data->history->peer->id, data->history->peer->id,
data->migrated ? data->migrated->peer->id : 0, data->migrated ? data->migrated->peer->id : 0,
universalId); universalId,
item->isScheduled());
} }
HistoryItem *Instance::itemByIndex(not_null<Data*> data, int index) { HistoryItem *Instance::itemByIndex(not_null<Data*> data, int index) {