tdesktop/Telegram/SourceFiles/history/view/history_view_pinned_tracker.h

62 lines
1.3 KiB
C
Raw Normal View History

/*
This file is part of Telegram Desktop,
the official desktop application for the Telegram messaging service.
For license and copyright information please follow this link:
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#pragma once
#include "history/view/history_view_pinned_bar.h"
class History;
namespace Data {
enum class LoadDirection : char;
} // namespace Data
namespace HistoryView {
class PinnedTracker final {
public:
2021-09-30 06:04:55 +00:00
using UniversalMsgId = MsgId;
explicit PinnedTracker(not_null<History*> history);
~PinnedTracker();
2020-10-12 09:41:05 +00:00
[[nodiscard]] rpl::producer<PinnedId> shownMessageId() const;
[[nodiscard]] PinnedId currentMessageId() const;
void trackAround(UniversalMsgId messageId);
2020-10-12 09:41:05 +00:00
void reset();
2020-10-20 16:29:24 +00:00
[[nodiscard]] rpl::lifetime &lifetime() {
return _lifetime;
}
private:
struct Slice {
std::vector<FullMsgId> ids;
std::optional<int> fullCount;
std::optional<int> skippedBefore;
std::optional<int> skippedAfter;
};
void clear();
void refreshViewer();
void refreshCurrentFromSlice();
const not_null<History*> _history;
PeerData *_migratedPeer = nullptr;
2020-10-12 09:41:05 +00:00
rpl::variable<PinnedId> _current;
rpl::lifetime _dataLifetime;
UniversalMsgId _aroundId = 0;
UniversalMsgId _viewerAroundId = 0;
Slice _slice;
rpl::lifetime _lifetime;
};
} // namespace HistoryView