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