2023-12-27 01:09:20 +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 "dialogs/dialogs_main_list.h"
|
|
|
|
|
|
|
|
namespace Main {
|
|
|
|
class Session;
|
|
|
|
} // namespace Main
|
|
|
|
|
|
|
|
namespace Data {
|
|
|
|
|
|
|
|
class Session;
|
|
|
|
class SavedSublist;
|
|
|
|
|
|
|
|
class SavedMessages final {
|
|
|
|
public:
|
|
|
|
explicit SavedMessages(not_null<Session*> owner);
|
|
|
|
~SavedMessages();
|
|
|
|
|
|
|
|
[[nodiscard]] bool supported() const;
|
|
|
|
|
|
|
|
[[nodiscard]] Session &owner() const;
|
|
|
|
[[nodiscard]] Main::Session &session() const;
|
|
|
|
|
|
|
|
[[nodiscard]] not_null<Dialogs::MainList*> chatsList();
|
|
|
|
[[nodiscard]] not_null<SavedSublist*> sublist(not_null<PeerData*> peer);
|
|
|
|
|
|
|
|
void loadMore();
|
|
|
|
void loadMore(not_null<SavedSublist*> sublist);
|
|
|
|
|
2023-12-31 04:49:55 +00:00
|
|
|
void apply(const MTPDupdatePinnedSavedDialogs &update);
|
|
|
|
void apply(const MTPDupdateSavedDialogPinned &update);
|
|
|
|
|
2023-12-27 01:09:20 +00:00
|
|
|
private:
|
2023-12-31 04:49:55 +00:00
|
|
|
void loadPinned();
|
|
|
|
void apply(const MTPmessages_SavedDialogs &result, bool pinned);
|
|
|
|
|
2024-01-01 19:42:18 +00:00
|
|
|
void sendLoadMore();
|
|
|
|
void sendLoadMore(not_null<SavedSublist*> sublist);
|
|
|
|
void sendLoadMoreRequests();
|
|
|
|
|
2023-12-27 01:09:20 +00:00
|
|
|
const not_null<Session*> _owner;
|
|
|
|
|
|
|
|
Dialogs::MainList _chatsList;
|
|
|
|
base::flat_map<
|
|
|
|
not_null<PeerData*>,
|
|
|
|
std::unique_ptr<SavedSublist>> _sublists;
|
|
|
|
|
|
|
|
base::flat_map<not_null<SavedSublist*>, mtpRequestId> _loadMoreRequests;
|
|
|
|
mtpRequestId _loadMoreRequestId = 0;
|
2023-12-31 04:49:55 +00:00
|
|
|
mtpRequestId _pinnedRequestId = 0;
|
2023-12-27 01:09:20 +00:00
|
|
|
|
|
|
|
TimeId _offsetDate = 0;
|
|
|
|
MsgId _offsetId = 0;
|
|
|
|
PeerData *_offsetPeer = nullptr;
|
|
|
|
|
2024-01-01 19:42:18 +00:00
|
|
|
SingleQueuedInvokation _loadMore;
|
|
|
|
base::flat_set<not_null<SavedSublist*>> _loadMoreSublistsScheduled;
|
|
|
|
bool _loadMoreScheduled = false;
|
|
|
|
|
2023-12-31 04:49:55 +00:00
|
|
|
bool _pinnedLoaded = false;
|
2023-12-27 01:09:20 +00:00
|
|
|
bool _unsupported = false;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace Data
|