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
|
|
|
|
|
2018-01-05 15:57:18 +00:00
|
|
|
#include "dialogs/dialogs_entry.h"
|
2018-01-09 17:08:31 +00:00
|
|
|
#include "data/data_messages.h"
|
2018-01-05 15:57:18 +00:00
|
|
|
|
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 {
|
|
|
|
|
2018-01-23 16:51:12 +00:00
|
|
|
class Session;
|
2018-01-29 13:52:09 +00:00
|
|
|
class Feed;
|
|
|
|
|
|
|
|
enum class FeedUpdateFlag {
|
|
|
|
Channels,
|
|
|
|
ChannelPhoto,
|
|
|
|
};
|
|
|
|
|
|
|
|
struct FeedUpdate {
|
|
|
|
not_null<Data::Feed*> feed;
|
|
|
|
FeedUpdateFlag flag;
|
|
|
|
};
|
2018-01-23 16:51:12 +00:00
|
|
|
|
2018-03-06 17:07:42 +00:00
|
|
|
//MessagePosition FeedPositionFromMTP(const MTPFeedPosition &position); // #feed
|
2018-01-05 15:57:18 +00:00
|
|
|
|
|
|
|
class Feed : public Dialogs::Entry {
|
2018-01-04 09:40:58 +00:00
|
|
|
public:
|
2018-01-23 16:51:12 +00:00
|
|
|
static constexpr auto kId = 1;
|
2018-01-31 17:10:29 +00:00
|
|
|
static constexpr auto kChannelsLimit = 1000;
|
2018-01-23 16:51:12 +00:00
|
|
|
|
2019-01-15 11:57:45 +00:00
|
|
|
Feed(not_null<Data::Session*> owner, FeedId id);
|
|
|
|
Feed(const Feed &) = delete;
|
|
|
|
Feed &operator=(const Feed &) = delete;
|
|
|
|
|
|
|
|
Data::Session &owner() const;
|
|
|
|
AuthSession &session() const;
|
2018-01-04 09:40:58 +00:00
|
|
|
|
2018-01-23 16:51:12 +00:00
|
|
|
FeedId id() const;
|
2018-01-04 09:40:58 +00:00
|
|
|
void registerOne(not_null<ChannelData*> channel);
|
|
|
|
void unregisterOne(not_null<ChannelData*> channel);
|
|
|
|
|
2019-01-15 11:57:45 +00:00
|
|
|
void updateChatListMessage(not_null<HistoryItem*> item);
|
2018-01-05 15:57:18 +00:00
|
|
|
void messageRemoved(not_null<HistoryItem*> item);
|
|
|
|
void historyCleared(not_null<History*> history);
|
|
|
|
|
2018-03-06 17:07:42 +00:00
|
|
|
//void applyDialog(const MTPDdialogFeed &data); // #feed
|
2018-01-31 17:10:29 +00:00
|
|
|
void setUnreadCounts(int unreadNonMutedCount, int unreadMutedCount);
|
2018-01-23 16:51:12 +00:00
|
|
|
void setUnreadPosition(const MessagePosition &position);
|
2018-01-31 17:10:29 +00:00
|
|
|
void unreadCountChanged(
|
2018-02-12 11:10:40 +00:00
|
|
|
int unreadCountDelta,
|
2018-01-31 17:10:29 +00:00
|
|
|
int mutedCountDelta);
|
2018-02-04 19:57:03 +00:00
|
|
|
rpl::producer<int> unreadCountValue() const;
|
2018-01-23 16:51:12 +00:00
|
|
|
MessagePosition unreadPosition() const;
|
|
|
|
rpl::producer<MessagePosition> unreadPositionChanges() const;
|
|
|
|
|
2018-02-03 19:52:35 +00:00
|
|
|
int unreadCount() const;
|
|
|
|
bool unreadCountKnown() const;
|
2018-01-31 17:10:29 +00:00
|
|
|
|
2018-05-11 14:03:53 +00:00
|
|
|
bool useProxyPromotion() const override;
|
2018-01-23 16:51:12 +00:00
|
|
|
bool toImportant() const override;
|
|
|
|
bool shouldBeInChatList() const override;
|
|
|
|
int chatListUnreadCount() const override;
|
2018-06-26 18:03:45 +00:00
|
|
|
bool chatListUnreadMark() const override;
|
2018-01-23 16:51:12 +00:00
|
|
|
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;
|
2018-02-20 17:53:55 +00:00
|
|
|
void changedInChatListHook(Dialogs::Mode list, bool added) override;
|
2018-01-22 09:33:09 +00:00
|
|
|
|
2018-01-05 15:57:18 +00:00
|
|
|
void loadUserpic() override;
|
|
|
|
void paintUserpic(
|
|
|
|
Painter &p,
|
|
|
|
int x,
|
|
|
|
int y,
|
|
|
|
int size) const override;
|
2018-01-04 19:54:35 +00:00
|
|
|
|
2018-01-29 13:52:09 +00:00
|
|
|
const std::vector<not_null<History*>> &channels() const;
|
2018-01-29 17:13:24 +00:00
|
|
|
int32 channelsHash() const;
|
2018-01-30 12:13:46 +00:00
|
|
|
bool channelsLoaded() const;
|
|
|
|
void setChannelsLoaded(bool loaded);
|
|
|
|
void setChannels(std::vector<not_null<ChannelData*>> channels);
|
2018-01-29 13:52:09 +00:00
|
|
|
|
2018-01-04 09:40:58 +00:00
|
|
|
private:
|
2018-01-22 09:33:09 +00:00
|
|
|
void indexNameParts();
|
2019-01-15 11:57:45 +00:00
|
|
|
void recountChatListMessage();
|
|
|
|
void setChatListMessageFromChannels();
|
|
|
|
bool justUpdateChatListMessage(not_null<HistoryItem*> item);
|
|
|
|
void updateChatListDate();
|
2018-02-08 09:20:14 +00:00
|
|
|
void changeChannelsList(
|
|
|
|
const std::vector<not_null<ChannelData*>> &add,
|
|
|
|
const std::vector<not_null<ChannelData*>> &remove);
|
2018-01-05 15:57:18 +00:00
|
|
|
|
2018-12-04 10:32:06 +00:00
|
|
|
template <typename PerformUpdate>
|
|
|
|
void updateUnreadCounts(PerformUpdate &&performUpdate);
|
|
|
|
|
2018-01-04 09:40:58 +00:00
|
|
|
FeedId _id = 0;
|
2019-01-15 11:57:45 +00:00
|
|
|
not_null<Data::Session*> _owner;
|
2018-01-05 15:57:18 +00:00
|
|
|
std::vector<not_null<History*>> _channels;
|
2018-02-08 09:20:14 +00:00
|
|
|
bool _settingChannels = false;
|
2018-01-30 12:13:46 +00:00
|
|
|
bool _channelsLoaded = false;
|
2018-01-05 15:57:18 +00:00
|
|
|
|
2018-01-22 09:33:09 +00:00
|
|
|
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-05 15:57:18 +00:00
|
|
|
|
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;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace Data
|