Show correct emoticon in interaction-seen status.

This commit is contained in:
John Preston 2021-09-19 10:31:41 +03:00
parent b02967a44e
commit a566405598
5 changed files with 22 additions and 15 deletions

View file

@ -117,7 +117,8 @@ void EmojiInteractions::startOutgoing(
if (!IsServerMsgId(item->id) || !item->history()->peer->isUser()) { if (!IsServerMsgId(item->id) || !item->history()->peer->isUser()) {
return; return;
} }
const auto emoji = chooseInteractionEmoji(item); const auto emoticon = item->originalText().text;
const auto emoji = chooseInteractionEmoji(emoticon);
if (!emoji) { if (!emoji) {
return; return;
} }
@ -145,6 +146,7 @@ void EmojiInteractions::startOutgoing(
media->checkStickerLarge(); media->checkStickerLarge();
const auto now = crl::now(); const auto now = crl::now();
animations.push_back({ animations.push_back({
.emoticon = emoticon,
.emoji = emoji, .emoji = emoji,
.document = document, .document = document,
.media = media, .media = media,
@ -195,6 +197,7 @@ void EmojiInteractions::startIncoming(
const auto media = document->createMediaView(); const auto media = document->createMediaView();
media->checkStickerLarge(); media->checkStickerLarge();
animations.push_back({ animations.push_back({
.emoticon = emoticon,
.emoji = emoji, .emoji = emoji,
.document = document, .document = document,
.media = media, .media = media,
@ -219,7 +222,7 @@ void EmojiInteractions::seenOutgoing(
if (const auto j = i->second.find(emoji); j != end(i->second)) { if (const auto j = i->second.find(emoji); j != end(i->second)) {
const auto last = j->second.lastDoneReceivedAt; const auto last = j->second.lastDoneReceivedAt;
if (!last || last + kAcceptSeenSinceRequest > crl::now()) { if (!last || last + kAcceptSeenSinceRequest > crl::now()) {
_seen.fire({ peer, emoji }); _seen.fire({ peer, emoticon });
} }
} }
} }
@ -263,7 +266,7 @@ auto EmojiInteractions::checkAnimations(
} else if (!lastStartedAt || lastStartedAt + kMinDelay <= now) { } else if (!lastStartedAt || lastStartedAt + kMinDelay <= now) {
animation.startedAt = now; animation.startedAt = now;
_playRequests.fire({ _playRequests.fire({
animation.emoji->text(), animation.emoticon,
item, item,
animation.media, animation.media,
animation.scheduledAt, animation.scheduledAt,
@ -316,7 +319,7 @@ void EmojiInteractions::sendAccumulatedOutgoing(
peer->input, peer->input,
MTPint(), // top_msg_id MTPint(), // top_msg_id
MTP_sendMessageEmojiInteraction( MTP_sendMessageEmojiInteraction(
MTP_string(emoji->text()), MTP_string(from->emoticon),
MTP_int(item->id), MTP_int(item->id),
MTP_dataJSON(MTP_bytes(ToJson(bunch)))) MTP_dataJSON(MTP_bytes(ToJson(bunch))))
)).done([=](const MTPBool &result, mtpRequestId requestId) { )).done([=](const MTPBool &result, mtpRequestId requestId) {

View file

@ -28,7 +28,7 @@ class Element;
namespace ChatHelpers { namespace ChatHelpers {
struct EmojiInteractionPlayRequest { struct EmojiInteractionPlayRequest {
QString emoji; QString emoticon;
not_null<HistoryItem*> item; not_null<HistoryItem*> item;
std::shared_ptr<Data::DocumentMedia> media; std::shared_ptr<Data::DocumentMedia> media;
crl::time shouldHaveStartedAt = 0; crl::time shouldHaveStartedAt = 0;
@ -45,7 +45,7 @@ struct EmojiInteractionsBunch {
struct EmojiInteractionSeen { struct EmojiInteractionSeen {
not_null<PeerData*> peer; not_null<PeerData*> peer;
not_null<EmojiPtr> emoji; QString emoticon;
}; };
class EmojiInteractions final { class EmojiInteractions final {
@ -78,6 +78,7 @@ public:
private: private:
struct Animation { struct Animation {
QString emoticon;
not_null<EmojiPtr> emoji; not_null<EmojiPtr> emoji;
not_null<DocumentData*> document; not_null<DocumentData*> document;
std::shared_ptr<Data::DocumentMedia> media; std::shared_ptr<Data::DocumentMedia> media;

View file

@ -61,14 +61,14 @@ void EmojiInteractions::play(
not_null<Element*> view) { not_null<Element*> view) {
if (_plays.empty()) { if (_plays.empty()) {
play( play(
std::move(request.emoji), std::move(request.emoticon),
view, view,
std::move(request.media), std::move(request.media),
request.incoming); request.incoming);
} else { } else {
const auto now = crl::now(); const auto now = crl::now();
_delayed.push_back({ _delayed.push_back({
request.emoji, request.emoticon,
view, view,
std::move(request.media), std::move(request.media),
now, now,
@ -79,7 +79,7 @@ void EmojiInteractions::play(
} }
void EmojiInteractions::play( void EmojiInteractions::play(
QString emoji, QString emoticon,
not_null<Element*> view, not_null<Element*> view,
std::shared_ptr<Data::DocumentMedia> media, std::shared_ptr<Data::DocumentMedia> media,
bool incoming) { bool incoming) {
@ -111,7 +111,7 @@ void EmojiInteractions::play(
.shift = shift, .shift = shift,
}); });
if (incoming) { if (incoming) {
_playStarted.fire(std::move(emoji)); _playStarted.fire(std::move(emoticon));
} }
if (const auto media = view->media()) { if (const auto media = view->media()) {
media->stickerClearLoopPlayed(); media->stickerClearLoopPlayed();
@ -254,8 +254,11 @@ void EmojiInteractions::checkDelayed() {
} }
auto good = std::move(*i); auto good = std::move(*i);
_delayed.erase(begin(_delayed), i + 1); _delayed.erase(begin(_delayed), i + 1);
const auto incoming = good.incoming; play(
play(std::move(good.emoji), good.view, std::move(good.media), incoming); std::move(good.emoticon),
good.view,
std::move(good.media),
good.incoming);
} }
rpl::producer<QRect> EmojiInteractions::updateRequests() const { rpl::producer<QRect> EmojiInteractions::updateRequests() const {

View file

@ -53,7 +53,7 @@ private:
bool finished = false; bool finished = false;
}; };
struct Delayed { struct Delayed {
QString emoji; QString emoticon;
not_null<Element*> view; not_null<Element*> view;
std::shared_ptr<Data::DocumentMedia> media; std::shared_ptr<Data::DocumentMedia> media;
crl::time shouldHaveStartedAt = 0; crl::time shouldHaveStartedAt = 0;
@ -63,7 +63,7 @@ private:
[[nodiscard]] QRect computeRect(not_null<Element*> view) const; [[nodiscard]] QRect computeRect(not_null<Element*> view) const;
void play( void play(
QString emoji, QString emoticon,
not_null<Element*> view, not_null<Element*> view,
std::shared_ptr<Data::DocumentMedia> media, std::shared_ptr<Data::DocumentMedia> media,
bool incoming); bool incoming);

View file

@ -667,7 +667,7 @@ void TopBarWidget::setActiveChat(
) | rpl::filter([=](const InteractionSeen &seen) { ) | rpl::filter([=](const InteractionSeen &seen) {
return (seen.peer == history->peer); return (seen.peer == history->peer);
}) | rpl::start_with_next([=](const InteractionSeen &seen) { }) | rpl::start_with_next([=](const InteractionSeen &seen) {
handleEmojiInteractionSeen(seen.emoji->text()); handleEmojiInteractionSeen(seen.emoticon);
}, lifetime()); }, lifetime());
} }
} }