2020-08-28 10:01:55 +00:00
|
|
|
/*
|
|
|
|
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 "base/weak_ptr.h"
|
|
|
|
|
|
|
|
class History;
|
2020-09-16 19:48:56 +00:00
|
|
|
class HistoryService;
|
2020-08-28 10:01:55 +00:00
|
|
|
|
|
|
|
namespace Data {
|
|
|
|
|
|
|
|
class Histories;
|
|
|
|
struct MessagePosition;
|
|
|
|
struct MessagesSlice;
|
|
|
|
struct MessageUpdate;
|
|
|
|
|
|
|
|
class RepliesList final : public base::has_weak_ptr {
|
|
|
|
public:
|
|
|
|
RepliesList(not_null<History*> history, MsgId rootId);
|
|
|
|
~RepliesList();
|
|
|
|
|
|
|
|
[[nodiscard]] rpl::producer<MessagesSlice> source(
|
|
|
|
MessagePosition aroundId,
|
|
|
|
int limitBefore,
|
|
|
|
int limitAfter);
|
|
|
|
|
|
|
|
[[nodiscard]] rpl::producer<int> fullCount() const;
|
|
|
|
|
2021-08-30 15:37:09 +00:00
|
|
|
[[nodiscard]] std::optional<int> fullUnreadCountAfter(
|
|
|
|
MsgId readTillId,
|
|
|
|
MsgId wasReadTillId,
|
|
|
|
std::optional<int> wasUnreadCountAfter) const;
|
|
|
|
|
2020-08-28 10:01:55 +00:00
|
|
|
private:
|
|
|
|
struct Viewer;
|
|
|
|
|
2020-09-08 11:19:44 +00:00
|
|
|
HistoryItem *lookupRoot();
|
2020-08-28 10:01:55 +00:00
|
|
|
[[nodiscard]] Histories &histories();
|
|
|
|
|
2020-09-04 16:11:36 +00:00
|
|
|
[[nodiscard]] rpl::producer<MessagesSlice> sourceFromServer(
|
|
|
|
MessagePosition aroundId,
|
|
|
|
int limitBefore,
|
|
|
|
int limitAfter);
|
2021-11-07 08:06:00 +00:00
|
|
|
void appendClientSideMessages(MessagesSlice &slice);
|
2020-09-04 16:11:36 +00:00
|
|
|
|
2020-08-28 10:01:55 +00:00
|
|
|
[[nodiscard]] bool buildFromData(not_null<Viewer*> viewer);
|
|
|
|
[[nodiscard]] bool applyUpdate(
|
|
|
|
not_null<Viewer*> viewer,
|
|
|
|
const MessageUpdate &update);
|
2020-10-23 13:35:43 +00:00
|
|
|
void injectRootMessageAndReverse(not_null<Viewer*> viewer);
|
|
|
|
void injectRootMessage(not_null<Viewer*> viewer);
|
2020-09-16 19:48:56 +00:00
|
|
|
void injectRootDivider(
|
|
|
|
not_null<HistoryItem*> root,
|
|
|
|
not_null<MessagesSlice*> slice);
|
2020-08-28 10:01:55 +00:00
|
|
|
bool processMessagesIsEmpty(const MTPmessages_Messages &result);
|
|
|
|
void loadAround(MsgId id);
|
|
|
|
void loadBefore();
|
|
|
|
void loadAfter();
|
|
|
|
|
|
|
|
const not_null<History*> _history;
|
|
|
|
const MsgId _rootId = 0;
|
|
|
|
std::vector<MsgId> _list;
|
|
|
|
std::optional<int> _skippedBefore;
|
|
|
|
std::optional<int> _skippedAfter;
|
|
|
|
rpl::variable<std::optional<int>> _fullCount;
|
|
|
|
rpl::event_stream<> _partLoaded;
|
|
|
|
std::optional<MsgId> _loadingAround;
|
2020-09-16 19:48:56 +00:00
|
|
|
HistoryService *_divider = nullptr;
|
|
|
|
bool _dividerWithComments = false;
|
2022-09-27 16:52:35 +00:00
|
|
|
bool _creating = false;
|
2020-08-28 10:01:55 +00:00
|
|
|
int _beforeId = 0;
|
|
|
|
int _afterId = 0;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace Data
|