mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-08-31 06:26:18 +00:00
Support basic feed display in chats list.
This commit is contained in:
@@ -7,11 +7,47 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "dialogs/dialogs_entry.h"
|
||||
|
||||
class ChannelData;
|
||||
|
||||
namespace Data {
|
||||
|
||||
class Feed {
|
||||
struct FeedPosition {
|
||||
FeedPosition() = default;
|
||||
FeedPosition(const MTPFeedPosition &position);
|
||||
FeedPosition(not_null<HistoryItem*> item);
|
||||
|
||||
explicit operator bool() const {
|
||||
return (msgId != 0);
|
||||
}
|
||||
|
||||
bool operator<(const FeedPosition &other) const;
|
||||
inline bool operator>(const FeedPosition &other) const {
|
||||
return other < *this;
|
||||
}
|
||||
inline bool operator<=(const FeedPosition &other) const {
|
||||
return !(other < *this);
|
||||
}
|
||||
inline bool operator>=(const FeedPosition &other) const {
|
||||
return !(*this < other);
|
||||
}
|
||||
inline bool operator==(const FeedPosition &other) const {
|
||||
return (date == other.date)
|
||||
&& (peerId == other.peerId)
|
||||
&& (msgId == other.msgId);
|
||||
}
|
||||
inline bool operator!=(const FeedPosition &other) const {
|
||||
return !(*this == other);
|
||||
}
|
||||
|
||||
TimeId date = 0;
|
||||
PeerId peerId = 0;
|
||||
MsgId msgId = 0;
|
||||
|
||||
};
|
||||
|
||||
class Feed : public Dialogs::Entry {
|
||||
public:
|
||||
Feed(FeedId id);
|
||||
|
||||
@@ -21,20 +57,44 @@ public:
|
||||
void registerOne(not_null<ChannelData*> channel);
|
||||
void unregisterOne(not_null<ChannelData*> channel);
|
||||
|
||||
void setUnreadCounts(int unreadCount, int unreadMutedCount);
|
||||
void updateLastMessage(not_null<HistoryItem*> item);
|
||||
void messageRemoved(not_null<HistoryItem*> item);
|
||||
void historyCleared(not_null<History*> history);
|
||||
|
||||
bool isPinnedDialog() const {
|
||||
return _pinnedIndex > 0;
|
||||
void setUnreadCounts(int unreadCount, int unreadMutedCount);
|
||||
void setUnreadPosition(const FeedPosition &position);
|
||||
|
||||
bool toImportant() const override {
|
||||
return false; // TODO feeds workmode
|
||||
}
|
||||
void cachePinnedIndex(int index);
|
||||
uint64 sortKeyInChatList() const;
|
||||
int chatListUnreadCount() const override {
|
||||
return _unreadCount;
|
||||
}
|
||||
bool chatListMutedBadge() const override {
|
||||
return _unreadCount <= _unreadMutedCount;
|
||||
}
|
||||
HistoryItem *chatsListItem() const override {
|
||||
return _lastMessage;
|
||||
}
|
||||
void loadUserpic() override;
|
||||
void paintUserpic(
|
||||
Painter &p,
|
||||
int x,
|
||||
int y,
|
||||
int size) const override;
|
||||
|
||||
private:
|
||||
void recountLastMessage();
|
||||
bool justSetLastMessage(not_null<HistoryItem*> item);
|
||||
|
||||
FeedId _id = 0;
|
||||
base::flat_set<not_null<ChannelData*>> _channels;
|
||||
std::vector<not_null<History*>> _channels;
|
||||
|
||||
HistoryItem *_lastMessage = nullptr;
|
||||
|
||||
FeedPosition _unreadPosition;
|
||||
int _unreadCount = 0;
|
||||
int _unreadMutedCount = 0;
|
||||
int _pinnedIndex = 0;
|
||||
bool _complete = false;
|
||||
|
||||
};
|
||||
|
Reference in New Issue
Block a user