tdesktop/Telegram/SourceFiles/data/data_folder.h

128 lines
3.6 KiB
C
Raw Normal View History

2018-01-04 09:40:58 +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_entry.h"
2018-01-09 17:08:31 +00:00
#include "data/data_messages.h"
2018-01-04 09:40:58 +00:00
class ChannelData;
2019-01-15 11:57:45 +00:00
class AuthSession;
2018-01-04 09:40:58 +00:00
namespace Data {
class Session;
2019-04-15 11:54:03 +00:00
class Folder;
2019-04-15 11:54:03 +00:00
enum class FolderUpdateFlag {
List,
};
2019-04-15 11:54:03 +00:00
struct FolderUpdate {
not_null<Data::Folder*> folder;
FolderUpdateFlag flag;
};
2018-03-06 17:07:42 +00:00
//MessagePosition FeedPositionFromMTP(const MTPFeedPosition &position); // #feed
2019-04-15 11:54:03 +00:00
class Folder : public Dialogs::Entry {
2018-01-04 09:40:58 +00:00
public:
static constexpr auto kId = 1;
2019-04-15 11:54:03 +00:00
Folder(not_null<Data::Session*> owner, FolderId id);
Folder(const Folder &) = delete;
Folder &operator=(const Folder &) = delete;
2019-01-15 11:57:45 +00:00
Data::Session &owner() const;
AuthSession &session() const;
2018-01-04 09:40:58 +00:00
2019-04-15 11:54:03 +00:00
FolderId id() const;
void registerOne(not_null<History*> history);
void unregisterOne(not_null<History*> history);
2018-01-04 09:40:58 +00:00
2019-01-15 11:57:45 +00:00
void updateChatListMessage(not_null<HistoryItem*> item);
void messageRemoved(not_null<HistoryItem*> item);
void historyCleared(not_null<History*> history);
void applyDialog(const MTPDdialogFolder &data);
void setUnreadCounts(int unreadNonMutedCount, int unreadMutedCount);
//void setUnreadPosition(const MessagePosition &position); // #feed
void unreadCountChanged(
int unreadCountDelta,
int mutedCountDelta);
2018-02-04 19:57:03 +00:00
rpl::producer<int> unreadCountValue() const;
//MessagePosition unreadPosition() const; // #feed
//rpl::producer<MessagePosition> unreadPositionChanges() const; // #feed
//void setUnreadMark(bool unread);
//bool unreadMark() const;
//int unreadCountForBadge() const; // unreadCount || unreadMark ? 1 : 0.
int unreadCount() const;
bool unreadCountKnown() const;
bool useProxyPromotion() const override;
bool toImportant() const override;
bool shouldBeInChatList() const override;
int chatListUnreadCount() const override;
2018-06-26 18:03:45 +00:00
bool chatListUnreadMark() const override;
bool chatListMutedBadge() const override;
2019-01-15 11:57:45 +00:00
HistoryItem *chatListMessage() const override;
bool chatListMessageKnown() const override;
void requestChatListMessage() override;
const QString &chatListName() const override;
const base::flat_set<QString> &chatListNameWords() const override;
const base::flat_set<QChar> &chatListFirstLetters() const override;
void changedInChatListHook(Dialogs::Mode list, bool added) override;
void loadUserpic() override;
void paintUserpic(
Painter &p,
int x,
int y,
int size) const override;
const std::vector<not_null<History*>> &histories() const;
bool historiesLoaded() const;
void setHistoriesLoaded(bool loaded);
//int32 chatsHash() const;
//void setChats(std::vector<not_null<PeerData*>> chats); // #feed
2018-01-04 09:40:58 +00:00
private:
void indexNameParts();
2019-01-15 11:57:45 +00:00
void recountChatListMessage();
void setChatListMessageFromChannels();
bool justUpdateChatListMessage(not_null<HistoryItem*> item);
void updateChatListDate();
2019-04-15 11:54:03 +00:00
void changeChatsList(
const std::vector<not_null<PeerData*>> &add,
const std::vector<not_null<PeerData*>> &remove);
2018-12-04 10:32:06 +00:00
template <typename PerformUpdate>
void updateUnreadCounts(PerformUpdate &&performUpdate);
2019-04-15 11:54:03 +00:00
FolderId _id = 0;
2019-01-15 11:57:45 +00:00
not_null<Data::Session*> _owner;
std::vector<not_null<History*>> _histories;
bool _settingHistories = false;
bool _historiesLoaded = false;
QString _name;
base::flat_set<QString> _nameWords;
base::flat_set<QChar> _nameFirstLetters;
2019-01-15 11:57:45 +00:00
std::optional<HistoryItem*> _chatListMessage;
2018-01-09 17:08:31 +00:00
rpl::variable<MessagePosition> _unreadPosition;
2018-09-21 16:28:46 +00:00
std::optional<int> _unreadCount;
2018-02-04 19:57:03 +00:00
rpl::event_stream<int> _unreadCountChanges;
2018-01-04 09:40:58 +00:00
int _unreadMutedCount = 0;
//bool _unreadMark = false;
2018-01-04 09:40:58 +00:00
};
} // namespace Data