tdesktop/Telegram/SourceFiles/data/data_feed.h

91 lines
2.2 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;
namespace Data {
class Session;
class Feed;
enum class FeedUpdateFlag {
Channels,
ChannelPhoto,
};
struct FeedUpdate {
not_null<Data::Feed*> feed;
FeedUpdateFlag flag;
};
2018-01-09 17:08:31 +00:00
MessagePosition FeedPositionFromMTP(const MTPFeedPosition &position);
class Feed : public Dialogs::Entry {
2018-01-04 09:40:58 +00:00
public:
static constexpr auto kId = 1;
Feed(FeedId id, not_null<Data::Session*> parent);
2018-01-04 09:40:58 +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);
void updateLastMessage(not_null<HistoryItem*> item);
void messageRemoved(not_null<HistoryItem*> item);
void historyCleared(not_null<History*> history);
2018-01-04 09:40:58 +00:00
void setUnreadCounts(int unreadCount, int unreadMutedCount);
void setUnreadPosition(const MessagePosition &position);
MessagePosition unreadPosition() const;
rpl::producer<MessagePosition> unreadPositionChanges() const;
bool toImportant() const override;
bool shouldBeInChatList() const override;
int chatListUnreadCount() const override;
bool chatListMutedBadge() const override;
HistoryItem *chatsListItem() const override;
const QString &chatsListName() const override;
const base::flat_set<QString> &chatsListNameWords() const override;
const base::flat_set<QChar> &chatsListFirstLetters() const override;
void loadUserpic() override;
void paintUserpic(
Painter &p,
int x,
int y,
int size) const override;
const std::vector<not_null<History*>> &channels() const;
2018-01-29 17:13:24 +00:00
int32 channelsHash() const;
2018-01-04 09:40:58 +00:00
private:
void indexNameParts();
void recountLastMessage();
bool justSetLastMessage(not_null<HistoryItem*> item);
2018-01-04 09:40:58 +00:00
FeedId _id = 0;
not_null<Data::Session*> _parent;
std::vector<not_null<History*>> _channels;
QString _name;
base::flat_set<QString> _nameWords;
base::flat_set<QChar> _nameFirstLetters;
HistoryItem *_lastMessage = nullptr;
2018-01-09 17:08:31 +00:00
rpl::variable<MessagePosition> _unreadPosition;
2018-01-04 09:40:58 +00:00
int _unreadCount = 0;
int _unreadMutedCount = 0;
};
} // namespace Data