mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-15 21:57:10 +02:00
Prepend colored default statuses in selector.
This commit is contained in:
parent
a256eb4bc8
commit
688cd70c91
4 changed files with 52 additions and 5 deletions
|
@ -586,6 +586,7 @@ inputStickerSetDice#e67f520e emoticon:string = InputStickerSet;
|
|||
inputStickerSetAnimatedEmojiAnimations#cde3739 = InputStickerSet;
|
||||
inputStickerSetPremiumGifts#c88b3b02 = InputStickerSet;
|
||||
inputStickerSetEmojiGenericAnimations#4c4d4ce = InputStickerSet;
|
||||
inputStickerSetEmojiDefaultStatuses#29d0f5ee = InputStickerSet;
|
||||
|
||||
stickerSet#2dd14edc flags:# archived:flags.1?true official:flags.2?true masks:flags.3?true animated:flags.5?true videos:flags.6?true emojis:flags.7?true installed_date:flags.0?int id:long access_hash:long title:string short_name:string thumbs:flags.4?Vector<PhotoSize> thumb_dc_id:flags.4?int thumb_version:flags.4?int thumb_document_id:flags.8?long count:int hash:int = StickerSet;
|
||||
|
||||
|
|
|
@ -46,6 +46,7 @@ EmojiStatuses::EmojiStatuses(not_null<Session*> owner)
|
|||
: _owner(owner)
|
||||
, _defaultRefreshTimer([=] { refreshDefault(); }) {
|
||||
refreshDefault();
|
||||
refreshColored();
|
||||
|
||||
base::timer_each(
|
||||
kRefreshDefaultListEach
|
||||
|
@ -68,6 +69,10 @@ void EmojiStatuses::refreshDefault() {
|
|||
requestDefault();
|
||||
}
|
||||
|
||||
void EmojiStatuses::refreshColored() {
|
||||
requestColored();
|
||||
}
|
||||
|
||||
void EmojiStatuses::refreshRecentDelayed() {
|
||||
if (_recentRequestId || _recentRequestScheduled) {
|
||||
return;
|
||||
|
@ -84,6 +89,7 @@ const std::vector<DocumentId> &EmojiStatuses::list(Type type) const {
|
|||
switch (type) {
|
||||
case Type::Recent: return _recent;
|
||||
case Type::Default: return _default;
|
||||
case Type::Colored: return _colored;
|
||||
}
|
||||
Unexpected("Type in EmojiStatuses::list.");
|
||||
}
|
||||
|
@ -191,6 +197,26 @@ void EmojiStatuses::requestDefault() {
|
|||
}).send();
|
||||
}
|
||||
|
||||
void EmojiStatuses::requestColored() {
|
||||
if (_coloredRequestId) {
|
||||
return;
|
||||
}
|
||||
auto &api = _owner->session().api();
|
||||
_coloredRequestId = api.request(MTPmessages_GetStickerSet(
|
||||
MTP_inputStickerSetEmojiDefaultStatuses(),
|
||||
MTP_int(0) // hash
|
||||
)).done([=](const MTPmessages_StickerSet &result) {
|
||||
_coloredRequestId = 0;
|
||||
result.match([&](const MTPDmessages_stickerSet &data) {
|
||||
updateColored(data);
|
||||
}, [](const MTPDmessages_stickerSetNotModified &) {
|
||||
LOG(("API Error: Unexpected messages.stickerSetNotModified."));
|
||||
});
|
||||
}).fail([=] {
|
||||
_coloredRequestId = 0;
|
||||
}).send();
|
||||
}
|
||||
|
||||
void EmojiStatuses::updateRecent(const MTPDaccount_emojiStatuses &data) {
|
||||
_recentHash = data.vhash().v;
|
||||
_recent = ListFromMTP(data);
|
||||
|
@ -203,6 +229,16 @@ void EmojiStatuses::updateDefault(const MTPDaccount_emojiStatuses &data) {
|
|||
_defaultUpdated.fire({});
|
||||
}
|
||||
|
||||
void EmojiStatuses::updateColored(const MTPDmessages_stickerSet &data) {
|
||||
const auto &list = data.vdocuments().v;
|
||||
_colored.clear();
|
||||
_colored.reserve(list.size());
|
||||
for (const auto &sticker : data.vdocuments().v) {
|
||||
_colored.push_back(_owner->processDocument(sticker)->id);
|
||||
}
|
||||
_coloredUpdated.fire({});
|
||||
}
|
||||
|
||||
void EmojiStatuses::set(DocumentId id) {
|
||||
auto &api = _owner->session().api();
|
||||
if (_sentRequestId) {
|
||||
|
|
|
@ -35,15 +35,18 @@ public:
|
|||
void refreshRecent();
|
||||
void refreshRecentDelayed();
|
||||
void refreshDefault();
|
||||
void refreshColored();
|
||||
|
||||
enum class Type {
|
||||
Recent,
|
||||
Default,
|
||||
Colored,
|
||||
};
|
||||
[[nodiscard]] const std::vector<DocumentId> &list(Type type) const;
|
||||
|
||||
[[nodiscard]] rpl::producer<> recentUpdates() const;
|
||||
[[nodiscard]] rpl::producer<> defaultUpdates() const;
|
||||
[[nodiscard]] rpl::producer<> coloredUpdates() const;
|
||||
|
||||
void set(DocumentId id);
|
||||
[[nodiscard]] bool setting() const;
|
||||
|
@ -53,9 +56,11 @@ public:
|
|||
private:
|
||||
void requestRecent();
|
||||
void requestDefault();
|
||||
void requestColored();
|
||||
|
||||
void updateRecent(const MTPDaccount_emojiStatuses &data);
|
||||
void updateDefault(const MTPDaccount_emojiStatuses &data);
|
||||
void updateColored(const MTPDmessages_stickerSet &data);
|
||||
|
||||
void processClearing();
|
||||
|
||||
|
@ -63,8 +68,10 @@ private:
|
|||
|
||||
std::vector<DocumentId> _recent;
|
||||
std::vector<DocumentId> _default;
|
||||
std::vector<DocumentId> _colored;
|
||||
rpl::event_stream<> _recentUpdated;
|
||||
rpl::event_stream<> _defaultUpdated;
|
||||
rpl::event_stream<> _coloredUpdated;
|
||||
|
||||
mtpRequestId _recentRequestId = 0;
|
||||
bool _recentRequestScheduled = false;
|
||||
|
@ -74,6 +81,8 @@ private:
|
|||
mtpRequestId _defaultRequestId = 0;
|
||||
uint64 _defaultHash = 0;
|
||||
|
||||
mtpRequestId _coloredRequestId = 0;
|
||||
|
||||
mtpRequestId _sentRequestId = 0;
|
||||
|
||||
base::flat_map<not_null<UserData*>, crl::time> _clearing;
|
||||
|
|
|
@ -247,13 +247,14 @@ void EmojiStatusPanel::show(
|
|||
not_null<QWidget*> button) {
|
||||
const auto self = controller->session().user();
|
||||
const auto &statuses = controller->session().data().emojiStatuses();
|
||||
const auto &recent = statuses.list(Data::EmojiStatuses::Type::Recent);
|
||||
const auto &other = statuses.list(Data::EmojiStatuses::Type::Default);
|
||||
auto list = statuses.list(Data::EmojiStatuses::Type::Recent);
|
||||
auto list = statuses.list(Data::EmojiStatuses::Type::Colored);
|
||||
list.insert(begin(list), 0);
|
||||
list.reserve(list.size() + other.size() + 1);
|
||||
for (const auto &otherId : other) {
|
||||
if (!ranges::contains(list, otherId)) {
|
||||
list.push_back(otherId);
|
||||
list.reserve(list.size() + recent.size() + other.size() + 1);
|
||||
for (const auto &id : ranges::views::concat(recent, other)) {
|
||||
if (!ranges::contains(list, id)) {
|
||||
list.push_back(id);
|
||||
}
|
||||
}
|
||||
if (!ranges::contains(list, self->emojiStatusId())) {
|
||||
|
|
Loading…
Add table
Reference in a new issue