Update API scheme to layer 155.

This commit is contained in:
John Preston 2023-03-08 14:06:08 +04:00
parent 0c165d1fb8
commit 7682ccf6a7
9 changed files with 34 additions and 16 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 427 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 770 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

View file

@ -407,6 +407,7 @@ updateChannelPinnedTopic#192efbe3 flags:# pinned:flags.0?true channel_id:long to
updateChannelPinnedTopics#fe198602 flags:# channel_id:long order:flags.0?Vector<int> = Update; updateChannelPinnedTopics#fe198602 flags:# channel_id:long order:flags.0?Vector<int> = Update;
updateUser#20529438 user_id:long = Update; updateUser#20529438 user_id:long = Update;
updateAutoSaveSettings#ec05b097 = Update; updateAutoSaveSettings#ec05b097 = Update;
updateGroupInvitePrivacyForbidden#ccf08ad6 user_id:long = Update;
updates.state#a56c2a3e pts:int qts:int date:int seq:int unread_count:int = updates.State; updates.state#a56c2a3e pts:int qts:int date:int seq:int unread_count:int = updates.State;
@ -1373,7 +1374,7 @@ availableReaction#c077ec01 flags:# inactive:flags.0?true premium:flags.2?true re
messages.availableReactionsNotModified#9f071957 = messages.AvailableReactions; messages.availableReactionsNotModified#9f071957 = messages.AvailableReactions;
messages.availableReactions#768e3aad hash:int reactions:Vector<AvailableReaction> = messages.AvailableReactions; messages.availableReactions#768e3aad hash:int reactions:Vector<AvailableReaction> = messages.AvailableReactions;
messagePeerReaction#b156fe9c flags:# big:flags.0?true unread:flags.1?true peer_id:Peer reaction:Reaction = MessagePeerReaction; messagePeerReaction#8c79b63c flags:# big:flags.0?true unread:flags.1?true peer_id:Peer date:int reaction:Reaction = MessagePeerReaction;
groupCallStreamChannel#80eb48af channel:int scale:int last_timestamp_ms:long = GroupCallStreamChannel; groupCallStreamChannel#80eb48af channel:int scale:int last_timestamp_ms:long = GroupCallStreamChannel;
@ -2040,4 +2041,4 @@ stats.getMegagroupStats#dcdf8607 flags:# dark:flags.0?true channel:InputChannel
stats.getMessagePublicForwards#5630281b channel:InputChannel msg_id:int offset_rate:int offset_peer:InputPeer offset_id:int limit:int = messages.Messages; stats.getMessagePublicForwards#5630281b channel:InputChannel msg_id:int offset_rate:int offset_peer:InputPeer offset_id:int limit:int = messages.Messages;
stats.getMessageStats#b6e0a3f5 flags:# dark:flags.0?true channel:InputChannel msg_id:int = stats.MessageStats; stats.getMessageStats#b6e0a3f5 flags:# dark:flags.0?true channel:InputChannel msg_id:int = stats.MessageStats;
// LAYER 154 // LAYER 155

View file

@ -111,6 +111,7 @@ struct Context {
struct Userpic { struct Userpic {
not_null<PeerData*> peer; not_null<PeerData*> peer;
TimeId date = 0; TimeId date = 0;
bool dateReacted = false;
QString customEntityData; QString customEntityData;
mutable Ui::PeerUserpicView view; mutable Ui::PeerUserpicView view;
mutable InMemoryKey uniqueKey; mutable InMemoryKey uniqueKey;
@ -301,14 +302,15 @@ struct State {
}; };
parsed.list.reserve(data.vreactions().v.size()); parsed.list.reserve(data.vreactions().v.size());
for (const auto &vote : data.vreactions().v) { for (const auto &vote : data.vreactions().v) {
vote.match([&](const auto &data) { const auto &data = vote.data();
parsed.list.push_back(PeerWithReaction{ parsed.list.push_back(PeerWithReaction{
.peerWithDate = { .peerWithDate = {
.peer = peerFromMTP(data.vpeer_id()), .peer = peerFromMTP(data.vpeer_id()),
}, .date = data.vdate().v,
.reaction = Data::ReactionFromMTP( .dateReacted = true,
data.vreaction()), },
}); .reaction = Data::ReactionFromMTP(
data.vreaction()),
}); });
} }
entry.data = std::move(parsed); entry.data = std::move(parsed);
@ -343,10 +345,11 @@ struct State {
peerWithDate.peer, peerWithDate.peer,
[](const PeerWithReaction &p) { [](const PeerWithReaction &p) {
return p.peerWithDate.peer; }); return p.peerWithDate.peer; });
if (i != end(list)) { if (i == end(list)) {
i->peerWithDate.date = peerWithDate.date;
} else {
list.push_back({ .peerWithDate = peerWithDate }); list.push_back({ .peerWithDate = peerWithDate });
} else if (!i->peerWithDate.date) {
i->peerWithDate.date = peerWithDate.date;
i->peerWithDate.dateReacted = peerWithDate.dateReacted;
} }
} }
reacted.read = std::move(read.list); reacted.read = std::move(read.list);
@ -394,6 +397,7 @@ bool UpdateUserpics(
struct ResolvedPeer { struct ResolvedPeer {
PeerData *peer = nullptr; PeerData *peer = nullptr;
TimeId date = 0; TimeId date = 0;
bool dateReacted = false;
ReactionId reaction; ReactionId reaction;
}; };
const auto peers = ranges::views::all( const auto peers = ranges::views::all(
@ -402,6 +406,7 @@ bool UpdateUserpics(
return ResolvedPeer{ return ResolvedPeer{
.peer = owner.peerLoaded(id.peerWithDate.peer), .peer = owner.peerLoaded(id.peerWithDate.peer),
.date = id.peerWithDate.date, .date = id.peerWithDate.date,
.dateReacted = id.peerWithDate.dateReacted,
.reaction = id.reaction, .reaction = id.reaction,
}; };
}) | ranges::views::filter([](ResolvedPeer resolved) { }) | ranges::views::filter([](ResolvedPeer resolved) {
@ -425,6 +430,7 @@ bool UpdateUserpics(
const auto i = ranges::find(was, peer, &Userpic::peer); const auto i = ranges::find(was, peer, &Userpic::peer);
if (i != end(was) && i->view.cloud) { if (i != end(was) && i->view.cloud) {
i->date = resolved.date; i->date = resolved.date;
i->dateReacted = resolved.dateReacted;
now.push_back(std::move(*i)); now.push_back(std::move(*i));
now.back().customEntityData = data; now.back().customEntityData = data;
continue; continue;
@ -432,6 +438,7 @@ bool UpdateUserpics(
now.push_back(Userpic{ now.push_back(Userpic{
.peer = peer, .peer = peer,
.date = resolved.date, .date = resolved.date,
.dateReacted = resolved.dateReacted,
.customEntityData = data, .customEntityData = data,
}); });
auto &userpic = now.back(); auto &userpic = now.back();
@ -479,12 +486,14 @@ void RegenerateParticipants(not_null<State*> state, int small, int large) {
if (was != end(old)) { if (was != end(old)) {
was->name = peer->name(); was->name = peer->name();
was->date = FormatReadDate(date, currentDate); was->date = FormatReadDate(date, currentDate);
was->dateReacted = userpic.dateReacted;
now.push_back(std::move(*was)); now.push_back(std::move(*was));
continue; continue;
} }
now.push_back({ now.push_back({
.name = peer->name(), .name = peer->name(),
.date = FormatReadDate(date, currentDate), .date = FormatReadDate(date, currentDate),
.dateReacted = userpic.dateReacted,
.customEntityData = userpic.customEntityData, .customEntityData = userpic.customEntityData,
.userpicLarge = GenerateUserpic(userpic, large), .userpicLarge = GenerateUserpic(userpic, large),
.userpicKey = userpic.uniqueKey, .userpicKey = userpic.uniqueKey,

View file

@ -37,6 +37,7 @@ enum class WhoReactedList {
struct WhoReadPeer { struct WhoReadPeer {
PeerId peer = 0; PeerId peer = 0;
TimeId date = 0; TimeId date = 0;
bool dateReacted = false;
friend inline bool operator==( friend inline bool operator==(
const WhoReadPeer &a, const WhoReadPeer &a,

View file

@ -1100,6 +1100,8 @@ whoReadDateTop: 20px;
whoReadDateSkip: 15px; whoReadDateSkip: 15px;
whoReadDateChecks: icon{{ "menu/read_ticks_s", windowSubTextFg }}; whoReadDateChecks: icon{{ "menu/read_ticks_s", windowSubTextFg }};
whoReadDateChecksOver: icon{{ "menu/read_ticks_s", windowSubTextFgOver }}; whoReadDateChecksOver: icon{{ "menu/read_ticks_s", windowSubTextFgOver }};
whoLikedDateHeart: icon{{ "menu/read_react_s", windowSubTextFg }};
whoLikedDateHeartOver: icon{{ "menu/read_react_s", windowSubTextFgOver }};
whoReadDateChecksPosition: point(-7px, -4px); whoReadDateChecksPosition: point(-7px, -4px);
whoReadDateStyle: TextStyle(defaultTextStyle) { whoReadDateStyle: TextStyle(defaultTextStyle) {
font: font(12px); font: font(12px);

View file

@ -74,6 +74,7 @@ using Text::CustomEmojiFactory;
struct EntryData { struct EntryData {
QString text; QString text;
QString date; QString date;
bool dateReacted = false;
QString customEntityData; QString customEntityData;
QImage userpic; QImage userpic;
Fn<void()> callback; Fn<void()> callback;
@ -493,6 +494,7 @@ private:
QImage _userpic; QImage _userpic;
int _textWidth = 0; int _textWidth = 0;
int _customSize = 0; int _customSize = 0;
bool _dateReacted = false;
}; };
@ -543,6 +545,7 @@ void WhoReactedListMenu::EntryAction::setData(EntryData &&data) {
{ data.date }, { data.date },
MenuTextOptions); MenuTextOptions);
} }
_dateReacted = data.dateReacted;
_custom = _customEmojiFactory(data.customEntityData, [=] { update(); }); _custom = _customEmojiFactory(data.customEntityData, [=] { update(); });
const auto ratio = style::DevicePixelRatio(); const auto ratio = style::DevicePixelRatio();
const auto size = Emoji::GetSizeNormal() / ratio; const auto size = Emoji::GetSizeNormal() / ratio;
@ -602,9 +605,9 @@ void WhoReactedListMenu::EntryAction::paint(Painter &&p) {
const auto iconPosition = QPoint( const auto iconPosition = QPoint(
st::defaultWhoRead.nameLeft, st::defaultWhoRead.nameLeft,
st::whoReadDateTop) + st::whoReadDateChecksPosition; st::whoReadDateTop) + st::whoReadDateChecksPosition;
const auto &icon = selected const auto &icon = _dateReacted
? st::whoReadDateChecksOver ? (selected ? st::whoLikedDateHeartOver : st::whoLikedDateHeart)
: st::whoReadDateChecks; : (selected ? st::whoReadDateChecksOver : st::whoReadDateChecks);
icon.paint(p, iconPosition, width()); icon.paint(p, iconPosition, width());
p.setPen(selected ? _st.itemFgShortcutOver : _st.itemFgShortcut); p.setPen(selected ? _st.itemFgShortcutOver : _st.itemFgShortcut);
_date.drawLeftElided( _date.drawLeftElided(
@ -713,6 +716,7 @@ void WhoReactedListMenu::populate(
append({ append({
.text = participant.name, .text = participant.name,
.date = participant.date, .date = participant.date,
.dateReacted = participant.dateReacted,
.customEntityData = participant.customEntityData, .customEntityData = participant.customEntityData,
.userpic = participant.userpicLarge, .userpic = participant.userpicLarge,
.callback = chosen, .callback = chosen,

View file

@ -20,6 +20,7 @@ class PopupMenu;
struct WhoReadParticipant { struct WhoReadParticipant {
QString name; QString name;
QString date; QString date;
bool dateReacted = false;
QString customEntityData; QString customEntityData;
QImage userpicSmall; QImage userpicSmall;
QImage userpicLarge; QImage userpicLarge;