2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-08-31 14:38:15 +00:00

Paint nice stories userpics in chats list.

This commit is contained in:
John Preston
2023-05-22 19:59:16 +04:00
parent 2c5d990e1c
commit 1d27c8c940
11 changed files with 675 additions and 7 deletions

View File

@@ -149,6 +149,10 @@ bool Stories::allLoaded() const {
return _allLoaded;
}
rpl::producer<> Stories::allChanged() const {
return _allChanged.events();
}
// #TODO stories testing
StoryId Stories::generate(
not_null<HistoryItem*> item,
@@ -244,10 +248,14 @@ StoryId Stories::generate(
void Stories::pushToBack(StoriesList &&list) {
const auto i = ranges::find(_all, list.user, &StoriesList::user);
if (i != end(_all)) {
if (*i == list) {
return;
}
*i = std::move(list);
} else {
_all.push_back(std::move(list));
}
_allChanged.fire({});
}
void Stories::pushToFront(StoriesList &&list) {

View File

@@ -30,6 +30,7 @@ struct StoryItem {
TextWithEntities caption;
TimeId date = 0;
StoryPrivacy privacy;
bool pinned = false;
friend inline bool operator==(StoryItem, StoryItem) = default;
};
@@ -37,8 +38,11 @@ struct StoryItem {
struct StoriesList {
not_null<UserData*> user;
std::vector<StoryItem> items;
StoryId readTill = 0;
int total = 0;
[[nodiscard]] bool unread() const;
friend inline bool operator==(StoriesList, StoriesList) = default;
};
@@ -61,11 +65,14 @@ public:
explicit Stories(not_null<Session*> owner);
~Stories();
[[nodiscard]] Session &owner() const;
void loadMore();
void apply(const MTPDupdateStories &data);
[[nodiscard]] const std::vector<StoriesList> &all();
[[nodiscard]] bool allLoaded() const;
[[nodiscard]] rpl::producer<> allChanged() const;
// #TODO stories testing
[[nodiscard]] StoryId generate(
@@ -76,7 +83,7 @@ public:
not_null<DocumentData*>> media);
private:
[[nodiscard]] StoriesList parse(const MTPUserStories &data);
[[nodiscard]] StoriesList parse(const MTPUserStories &stories);
[[nodiscard]] std::optional<StoryItem> parse(const MTPDstoryItem &data);
void pushToBack(StoriesList &&list);
@@ -85,6 +92,7 @@ private:
const not_null<Session*> _owner;
std::vector<StoriesList> _all;
rpl::event_stream<> _allChanged;
QString _state;
bool _allLoaded = false;