2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-08-31 06:26:18 +00:00

Move App::histories to Data::Session.

This commit is contained in:
John Preston
2019-01-03 16:36:01 +04:00
parent 0d6a36e187
commit 1f8626b383
49 changed files with 1479 additions and 1366 deletions

View File

@@ -49,6 +49,12 @@ class Feed;
enum class FeedUpdateFlag;
struct FeedUpdate;
struct WallPaper {
int32 id = 0;
ImagePtr thumb;
ImagePtr full;
};
class Session final {
public:
using ViewElement = HistoryView::Element;
@@ -60,6 +66,8 @@ public:
return *_session;
}
void clear();
void startExport(PeerData *peer = nullptr);
void startExport(const MTPInputPeer &singlePeer);
void suggestStartExport(TimeId availableAt);
@@ -77,6 +85,39 @@ public:
Storage::Cache::Database &cache();
[[nodiscard]] not_null<PeerData*> peer(PeerId id);
[[nodiscard]] not_null<UserData*> user(UserId id);
[[nodiscard]] not_null<ChatData*> chat(ChatId id);
[[nodiscard]] not_null<ChannelData*> channel(ChannelId id);
[[nodiscard]] PeerData *peerLoaded(PeerId id) const;
[[nodiscard]] UserData *userLoaded(UserId id) const;
[[nodiscard]] ChatData *chatLoaded(ChatId id) const;
[[nodiscard]] ChannelData *channelLoaded(ChannelId id) const;
not_null<UserData*> user(const MTPUser &data);
not_null<PeerData*> chat(const MTPChat &data);
// Returns last user, if there were any.
UserData *processUsers(const MTPVector<MTPUser> &data);
PeerData *processChats(const MTPVector<MTPChat> &data);
void enumerateUsers(Fn<void(not_null<UserData*>)> action) const;
void enumerateGroups(Fn<void(not_null<PeerData*>)> action) const;
void enumerateChannels(Fn<void(not_null<ChannelData*>)> action) const;
[[nodiscard]] PeerData *peerByUsername(const QString &username) const;
not_null<History*> history(PeerId peerId);
History *historyLoaded(PeerId peerId) const;
not_null<History*> history(not_null<const PeerData*> peer);
History *historyLoaded(const PeerData *peer);
void registerSendAction(
not_null<History*> history,
not_null<UserData*> user,
const MTPSendMessageAction &action,
TimeId when);
[[nodiscard]] base::Variable<bool> &contactsLoaded() {
return _contactsLoaded;
}
@@ -247,6 +288,34 @@ public:
void markMediaRead(not_null<const DocumentData*> document);
void requestPollViewRepaint(not_null<const PollData*> poll);
HistoryItem *addNewMessage(const MTPMessage &data, NewMessageType type);
struct SendActionAnimationUpdate {
not_null<History*> history;
int width = 0;
int height = 0;
bool textUpdated = false;
};
[[nodiscard]] auto sendActionAnimationUpdated() const
-> rpl::producer<SendActionAnimationUpdate>;
void updateSendActionAnimation(SendActionAnimationUpdate &&update);
void updateSendActionAnimation();
int unreadBadge() const;
bool unreadBadgeMuted() const;
int unreadBadgeIgnoreOne(History *history) const;
bool unreadBadgeMutedIgnoreOne(History *history) const;
int unreadOnlyMutedBadge() const;
void unreadIncrement(int count, bool muted);
void unreadMuteChanged(int count, bool muted);
void unreadEntriesChanged(
int withUnreadDelta,
int mutedWithUnreadDelta);
void selfDestructIn(not_null<HistoryItem*> item, TimeMs delay);
not_null<PhotoData*> photo(PhotoId id);
not_null<PhotoData*> photo(const MTPPhoto &data);
not_null<PhotoData*> photo(const MTPDphoto &data);
@@ -452,11 +521,30 @@ public:
return _groups;
}
int wallpapersCount() const;
const WallPaper &wallpaper(int index) const;
void setWallpapers(const QVector<MTPWallPaper> &data);
void clearLocalStorage();
private:
void suggestStartExport();
void setupContactViewsViewer();
void setupChannelLeavingViewer();
void checkSelfDestructItems();
int computeUnreadBadge(
int full,
int muted,
int entriesFull,
int entriesMuted) const;
bool computeUnreadBadgeMuted(
int full,
int muted,
int entriesFull,
int entriesMuted) const;
void photoApplyFields(
not_null<PhotoData*> photo,
const MTPPhoto &data);
@@ -554,6 +642,8 @@ private:
const MTPMessageMedia &media,
TimeId date);
void step_typings(TimeMs ms, bool timer);
not_null<AuthSession*> _session;
Storage::DatabasePointer _cache;
@@ -602,25 +692,37 @@ private:
Stickers::Order _archivedStickerSetsOrder;
Stickers::SavedGifs _savedGifs;
int _unreadFull = 0;
int _unreadMuted = 0;
int _unreadEntriesFull = 0;
int _unreadEntriesMuted = 0;
base::Timer _selfDestructTimer;
std::vector<FullMsgId> _selfDestructItems;
// When typing in this history started.
base::flat_map<not_null<History*>, TimeMs> _sendActions;
BasicAnimation _a_sendActions;
std::unordered_map<
PhotoId,
std::unique_ptr<PhotoData>> _photos;
std::map<
std::unordered_map<
not_null<const PhotoData*>,
base::flat_set<not_null<HistoryItem*>>> _photoItems;
std::unordered_map<
DocumentId,
std::unique_ptr<DocumentData>> _documents;
std::map<
std::unordered_map<
not_null<const DocumentData*>,
base::flat_set<not_null<HistoryItem*>>> _documentItems;
std::unordered_map<
WebPageId,
std::unique_ptr<WebPageData>> _webpages;
std::map<
std::unordered_map<
not_null<const WebPageData*>,
base::flat_set<not_null<HistoryItem*>>> _webpageItems;
std::map<
std::unordered_map<
not_null<const WebPageData*>,
base::flat_set<not_null<ViewElement*>>> _webpageViews;
std::unordered_map<
@@ -632,16 +734,16 @@ private:
std::unordered_map<
GameId,
std::unique_ptr<GameData>> _games;
std::map<
std::unordered_map<
not_null<const GameData*>,
base::flat_set<not_null<ViewElement*>>> _gameViews;
std::map<
std::unordered_map<
not_null<const PollData*>,
base::flat_set<not_null<ViewElement*>>> _pollViews;
std::map<
std::unordered_map<
UserId,
base::flat_set<not_null<HistoryItem*>>> _contactItems;
std::map<
std::unordered_map<
UserId,
base::flat_set<not_null<ViewElement*>>> _contactViews;
base::flat_map<
@@ -656,7 +758,7 @@ private:
base::flat_map<FeedId, std::unique_ptr<Feed>> _feeds;
rpl::variable<FeedId> _defaultFeedId = FeedId();
Groups _groups;
std::map<
std::unordered_map<
not_null<const HistoryItem*>,
std::vector<not_null<ViewElement*>>> _views;
@@ -671,6 +773,9 @@ private:
std::unordered_set<not_null<const PeerData*>> _mutedPeers;
base::Timer _unmuteByFinishedTimer;
std::unordered_map<PeerId, std::unique_ptr<PeerData>> _peers;
std::unordered_map<PeerId, std::unique_ptr<History>> _histories;
MessageIdsList _mimeForwardIds;
using CredentialsWithGeneration = std::pair<
@@ -680,6 +785,10 @@ private:
rpl::event_stream<> _newAuthorizationChecks;
rpl::event_stream<SendActionAnimationUpdate> _sendActionAnimationUpdate;
std::vector<WallPaper> _wallpapers;
rpl::lifetime _lifetime;
};