mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Fixed sending animation from inline bots with unexpected result type.
This commit is contained in:
parent
34f6c6b23f
commit
0b336a2954
11 changed files with 51 additions and 12 deletions
|
@ -1103,6 +1103,7 @@ bool FieldAutocomplete::Inner::chooseAtIndex(
|
||||||
stickerBoundingBox()));
|
stickerBoundingBox()));
|
||||||
contentRect.moveCenter(bounding.center());
|
contentRect.moveCenter(bounding.center());
|
||||||
return {
|
return {
|
||||||
|
Ui::MessageSendingAnimationFrom::Type::Sticker,
|
||||||
_controller->session().data().nextLocalMessageId(),
|
_controller->session().data().nextLocalMessageId(),
|
||||||
mapToGlobal(std::move(contentRect)),
|
mapToGlobal(std::move(contentRect)),
|
||||||
};
|
};
|
||||||
|
|
|
@ -447,6 +447,7 @@ void GifsListWidget::selectInlineResult(
|
||||||
const auto rect = item->innerContentRect().translated(
|
const auto rect = item->innerContentRect().translated(
|
||||||
_mosaic.findRect(index).topLeft());
|
_mosaic.findRect(index).topLeft());
|
||||||
return Ui::MessageSendingAnimationFrom{
|
return Ui::MessageSendingAnimationFrom{
|
||||||
|
.type = Ui::MessageSendingAnimationFrom::Type::Gif,
|
||||||
.localId = controller()->session().data().nextLocalMessageId(),
|
.localId = controller()->session().data().nextLocalMessageId(),
|
||||||
.globalStartGeometry = mapToGlobal(rect),
|
.globalStartGeometry = mapToGlobal(rect),
|
||||||
.crop = true,
|
.crop = true,
|
||||||
|
|
|
@ -2529,6 +2529,7 @@ Ui::MessageSendingAnimationFrom StickersListWidget::messageSentAnimationInfo(
|
||||||
(rect.height() - size.height()) / 2);
|
(rect.height() - size.height()) / 2);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
.type = Ui::MessageSendingAnimationFrom::Type::Sticker,
|
||||||
.localId = session().data().nextLocalMessageId(),
|
.localId = session().data().nextLocalMessageId(),
|
||||||
.globalStartGeometry = mapToGlobal(
|
.globalStartGeometry = mapToGlobal(
|
||||||
QRect(rect.topLeft() + innerPos, size)),
|
QRect(rect.topLeft() + innerPos, size)),
|
||||||
|
|
|
@ -5391,7 +5391,8 @@ void HistoryWidget::startItemRevealAnimations() {
|
||||||
void HistoryWidget::startMessageSendingAnimation(
|
void HistoryWidget::startMessageSendingAnimation(
|
||||||
not_null<HistoryItem*> item) {
|
not_null<HistoryItem*> item) {
|
||||||
auto &sendingAnimation = controller()->sendingAnimation();
|
auto &sendingAnimation = controller()->sendingAnimation();
|
||||||
if (!sendingAnimation.hasLocalMessage(item->fullId().msg)) {
|
if (!sendingAnimation.hasLocalMessage(item->fullId().msg)
|
||||||
|
|| !sendingAnimation.checkExpectedType(item)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Assert(item->mainView() != nullptr);
|
Assert(item->mainView() != nullptr);
|
||||||
|
|
|
@ -1581,7 +1581,8 @@ void ListWidget::startItemRevealAnimations() {
|
||||||
void ListWidget::startMessageSendingAnimation(
|
void ListWidget::startMessageSendingAnimation(
|
||||||
not_null<HistoryItem*> item) {
|
not_null<HistoryItem*> item) {
|
||||||
auto &sendingAnimation = controller()->sendingAnimation();
|
auto &sendingAnimation = controller()->sendingAnimation();
|
||||||
if (!sendingAnimation.hasLocalMessage(item->fullId().msg)) {
|
if (!sendingAnimation.hasLocalMessage(item->fullId().msg)
|
||||||
|
|| !sendingAnimation.checkExpectedType(item)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -73,9 +73,6 @@ public:
|
||||||
bool hasRightSkip() const override {
|
bool hasRightSkip() const override {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
bool hasSendingAnimation() const override {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void paint(Painter &p, const QRect &clip, const PaintContext *context) const override;
|
void paint(Painter &p, const QRect &clip, const PaintContext *context) const override;
|
||||||
TextState getState(
|
TextState getState(
|
||||||
|
@ -194,9 +191,6 @@ public:
|
||||||
bool hasRightSkip() const override {
|
bool hasRightSkip() const override {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
bool hasSendingAnimation() const override {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
void preload() const override;
|
void preload() const override;
|
||||||
|
|
||||||
void paint(Painter &p, const QRect &clip, const PaintContext *context) const override;
|
void paint(Painter &p, const QRect &clip, const PaintContext *context) const override;
|
||||||
|
|
|
@ -83,9 +83,6 @@ public:
|
||||||
virtual bool hasRightSkip() const {
|
virtual bool hasRightSkip() const {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
virtual bool hasSendingAnimation() const {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
Result *getResult() const;
|
Result *getResult() const;
|
||||||
DocumentData *getDocument() const;
|
DocumentData *getDocument() const;
|
||||||
|
|
|
@ -270,12 +270,22 @@ void Inner::selectInlineResult(
|
||||||
const auto document = item->getDocument()
|
const auto document = item->getDocument()
|
||||||
? item->getDocument()
|
? item->getDocument()
|
||||||
: item->getPreviewDocument();
|
: item->getPreviewDocument();
|
||||||
if (options.scheduled || !item->hasSendingAnimation()) {
|
if (options.scheduled
|
||||||
|
|| item->isFullLine()
|
||||||
|
|| !document
|
||||||
|
|| (!document->sticker() && !document->isGifv())) {
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
using Type = Ui::MessageSendingAnimationFrom::Type;
|
||||||
|
const auto type = document->sticker()
|
||||||
|
? Type::Sticker
|
||||||
|
: document->isGifv()
|
||||||
|
? Type::Gif
|
||||||
|
: Type::None;
|
||||||
const auto rect = item->innerContentRect().translated(
|
const auto rect = item->innerContentRect().translated(
|
||||||
_mosaic.findRect(index).topLeft());
|
_mosaic.findRect(index).topLeft());
|
||||||
return {
|
return {
|
||||||
|
.type = type,
|
||||||
.localId = _controller->session().data().nextLocalMessageId(),
|
.localId = _controller->session().data().nextLocalMessageId(),
|
||||||
.globalStartGeometry = mapToGlobal(rect),
|
.globalStartGeometry = mapToGlobal(rect),
|
||||||
.crop = document->isGifv(),
|
.crop = document->isGifv(),
|
||||||
|
|
|
@ -10,6 +10,12 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
|
|
||||||
struct MessageSendingAnimationFrom {
|
struct MessageSendingAnimationFrom {
|
||||||
|
enum class Type {
|
||||||
|
None,
|
||||||
|
Sticker,
|
||||||
|
Gif,
|
||||||
|
};
|
||||||
|
Type type = Type::None;
|
||||||
std::optional<MsgId> localId;
|
std::optional<MsgId> localId;
|
||||||
QRect globalStartGeometry;
|
QRect globalStartGeometry;
|
||||||
bool crop = false;
|
bool crop = false;
|
||||||
|
|
|
@ -7,6 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
*/
|
*/
|
||||||
#include "ui/effects/message_sending_animation_controller.h"
|
#include "ui/effects/message_sending_animation_controller.h"
|
||||||
|
|
||||||
|
#include "data/data_document.h"
|
||||||
#include "data/data_session.h"
|
#include "data/data_session.h"
|
||||||
#include "history/history_item.h"
|
#include "history/history_item.h"
|
||||||
#include "history/view/history_view_element.h"
|
#include "history/view/history_view_element.h"
|
||||||
|
@ -417,4 +418,29 @@ void MessageSendingAnimationController::clear() {
|
||||||
_processing.clear();
|
_processing.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool MessageSendingAnimationController::checkExpectedType(
|
||||||
|
not_null<HistoryItem*> item) {
|
||||||
|
const auto it = _itemSendPending.find(item->fullId().msg);
|
||||||
|
if (it == end(_itemSendPending)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
const auto type = it->second.type;
|
||||||
|
const auto isSticker = type == MessageSendingAnimationFrom::Type::Sticker;
|
||||||
|
const auto isGif = type == MessageSendingAnimationFrom::Type::Gif;
|
||||||
|
if (isSticker || isGif) {
|
||||||
|
if (item->emptyText()) {
|
||||||
|
if (const auto media = item->media()) {
|
||||||
|
if (const auto document = media->document()) {
|
||||||
|
if ((isGif && document->isGifv())
|
||||||
|
|| (isSticker && document->sticker())) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_itemSendPending.erase(it);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace Ui
|
} // namespace Ui
|
||||||
|
|
|
@ -39,6 +39,7 @@ public:
|
||||||
|
|
||||||
[[nodiscard]] bool hasLocalMessage(MsgId msgId) const;
|
[[nodiscard]] bool hasLocalMessage(MsgId msgId) const;
|
||||||
[[nodiscard]] bool hasAnimatedMessage(not_null<HistoryItem*> item) const;
|
[[nodiscard]] bool hasAnimatedMessage(not_null<HistoryItem*> item) const;
|
||||||
|
[[nodiscard]] bool checkExpectedType(not_null<HistoryItem*> item);
|
||||||
|
|
||||||
void clear();
|
void clear();
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue