mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-16 22:27:20 +02:00
Send story reactions as single-emoji messages.
This commit is contained in:
parent
43af9fd87e
commit
10d64d6bdf
8 changed files with 57 additions and 9 deletions
|
@ -3874,7 +3874,7 @@ void HistoryWidget::send(Api::SendOptions options) {
|
|||
? _previewData->id
|
||||
: WebPageId(0));
|
||||
|
||||
auto message = ApiWrap::MessageToSend(prepareSendAction(options));
|
||||
auto message = Api::MessageToSend(prepareSendAction(options));
|
||||
message.textWithTags = _field->getTextWithAppliedMarkdown();
|
||||
message.webPageId = webPageId;
|
||||
|
||||
|
|
|
@ -1166,7 +1166,7 @@ void RepliesWidget::send(Api::SendOptions options) {
|
|||
|
||||
const auto webPageId = _composeControls->webPageId();
|
||||
|
||||
auto message = ApiWrap::MessageToSend(prepareSendAction(options));
|
||||
auto message = Api::MessageToSend(prepareSendAction(options));
|
||||
message.textWithTags = _composeControls->getTextWithAppliedMarkdown();
|
||||
message.webPageId = webPageId;
|
||||
|
||||
|
@ -2507,8 +2507,7 @@ void RepliesWidget::listSendBotCommand(
|
|||
_history->peer,
|
||||
command,
|
||||
context);
|
||||
auto message = ApiWrap::MessageToSend(
|
||||
prepareSendAction({}));
|
||||
auto message = Api::MessageToSend(prepareSendAction({}));
|
||||
message.textWithTags = { text };
|
||||
session().api().sendMessage(std::move(message));
|
||||
finishSending();
|
||||
|
|
|
@ -587,7 +587,7 @@ void ScheduledWidget::send() {
|
|||
void ScheduledWidget::send(Api::SendOptions options) {
|
||||
const auto webPageId = _composeControls->webPageId();
|
||||
|
||||
auto message = ApiWrap::MessageToSend(prepareSendAction(options));
|
||||
auto message = Api::MessageToSend(prepareSendAction(options));
|
||||
message.textWithTags = _composeControls->getTextWithAppliedMarkdown();
|
||||
message.webPageId = webPageId;
|
||||
|
||||
|
@ -1235,7 +1235,7 @@ void ScheduledWidget::listSendBotCommand(
|
|||
_history->peer,
|
||||
command,
|
||||
context);
|
||||
auto message = ApiWrap::MessageToSend(prepareSendAction(options));
|
||||
auto message = Api::MessageToSend(prepareSendAction(options));
|
||||
message.textWithTags = { text };
|
||||
session().api().sendMessage(std::move(message));
|
||||
};
|
||||
|
|
|
@ -167,6 +167,11 @@ Controller::Controller(not_null<Delegate*> delegate)
|
|||
}
|
||||
}, _lifetime);
|
||||
|
||||
_reactions->chosen(
|
||||
) | rpl::start_with_next([=](const Data::ReactionId &id) {
|
||||
_replyArea->sendReaction(id);
|
||||
}, _lifetime);
|
||||
|
||||
_delegate->storiesLayerShown(
|
||||
) | rpl::start_with_next([=](bool shown) {
|
||||
_layerShown = shown;
|
||||
|
|
|
@ -143,9 +143,8 @@ void Reactions::create() {
|
|||
_selector->chosen(
|
||||
) | rpl::start_with_next([=](
|
||||
HistoryView::Reactions::ChosenReaction reaction) {
|
||||
_chosen.fire_copy(reaction.id);
|
||||
hide();
|
||||
//reaction.context = itemId;
|
||||
//chosen(std::move(reaction));
|
||||
}, _selector->lifetime());
|
||||
|
||||
_selector->premiumPromoChosen() | rpl::start_with_next([=] {
|
||||
|
|
|
@ -9,6 +9,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
|
||||
#include "ui/effects/animations.h"
|
||||
|
||||
namespace Data {
|
||||
struct ReactionId;
|
||||
} // namespace Data
|
||||
|
||||
namespace HistoryView::Reactions {
|
||||
class Selector;
|
||||
} // namespace HistoryView::Reactions
|
||||
|
@ -29,6 +33,9 @@ public:
|
|||
[[nodiscard]] rpl::producer<bool> expandedValue() const {
|
||||
return _expanded.value();
|
||||
}
|
||||
[[nodiscard]] rpl::producer<Data::ReactionId> chosen() const {
|
||||
return _chosen.events();
|
||||
}
|
||||
|
||||
void show();
|
||||
void hide();
|
||||
|
@ -47,6 +54,7 @@ private:
|
|||
std::unique_ptr<Ui::RpWidget> _parent;
|
||||
std::unique_ptr<HistoryView::Reactions::Selector> _selector;
|
||||
std::vector<std::unique_ptr<Hiding>> _hiding;
|
||||
rpl::event_stream<Data::ReactionId> _chosen;
|
||||
Ui::Animations::Simple _showing;
|
||||
rpl::variable<float64> _shownValue;
|
||||
rpl::variable<bool> _expanded;
|
||||
|
|
|
@ -17,6 +17,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "chat_helpers/tabbed_selector.h"
|
||||
#include "core/file_utilities.h"
|
||||
#include "core/mime_type.h"
|
||||
#include "data/stickers/data_custom_emoji.h"
|
||||
#include "data/data_document.h"
|
||||
#include "data/data_message_reaction_id.h"
|
||||
#include "data/data_session.h"
|
||||
#include "data/data_user.h"
|
||||
#include "history/view/controls/compose_controls_common.h"
|
||||
|
@ -101,13 +104,39 @@ void ReplyArea::initGeometry() {
|
|||
}, _lifetime);
|
||||
}
|
||||
|
||||
void ReplyArea::sendReaction(const Data::ReactionId &id) {
|
||||
Expects(_data.user != nullptr);
|
||||
|
||||
auto message = Api::MessageToSend(prepareSendAction({}));
|
||||
if (const auto emoji = id.emoji(); !emoji.isEmpty()) {
|
||||
message.textWithTags = { emoji };
|
||||
} else if (const auto customId = id.custom()) {
|
||||
const auto document = _data.user->owner().document(customId);
|
||||
if (const auto sticker = document->sticker()) {
|
||||
const auto text = sticker->alt;
|
||||
const auto id = Data::SerializeCustomEmojiId(customId);
|
||||
message.textWithTags = {
|
||||
text,
|
||||
{ { 0, text.size(), Ui::InputField::CustomEmojiLink(id) } }
|
||||
};
|
||||
}
|
||||
}
|
||||
if (!message.textWithTags.empty()) {
|
||||
send(std::move(message), {});
|
||||
}
|
||||
}
|
||||
|
||||
void ReplyArea::send(Api::SendOptions options) {
|
||||
const auto webPageId = _controls->webPageId();
|
||||
|
||||
auto message = ApiWrap::MessageToSend(prepareSendAction(options));
|
||||
auto message = Api::MessageToSend(prepareSendAction(options));
|
||||
message.textWithTags = _controls->getTextWithAppliedMarkdown();
|
||||
message.webPageId = webPageId;
|
||||
|
||||
send(std::move(message), options);
|
||||
}
|
||||
|
||||
void ReplyArea::send(Api::MessageToSend message, Api::SendOptions options) {
|
||||
const auto error = GetErrorTextForSending(
|
||||
_data.user,
|
||||
{
|
||||
|
|
|
@ -15,8 +15,13 @@ enum class SendMediaType;
|
|||
namespace Api {
|
||||
struct SendAction;
|
||||
struct SendOptions;
|
||||
struct MessageToSend;
|
||||
} // namespace Api
|
||||
|
||||
namespace Data {
|
||||
struct ReactionId;
|
||||
} // namespace Data
|
||||
|
||||
namespace HistoryView {
|
||||
class ComposeControls;
|
||||
} // namespace HistoryView
|
||||
|
@ -56,6 +61,7 @@ public:
|
|||
~ReplyArea();
|
||||
|
||||
void show(ReplyAreaData data);
|
||||
void sendReaction(const Data::ReactionId &id);
|
||||
|
||||
[[nodiscard]] rpl::producer<bool> focusedValue() const;
|
||||
[[nodiscard]] rpl::producer<bool> activeValue() const;
|
||||
|
@ -67,6 +73,8 @@ private:
|
|||
[[nodiscard]] Main::Session &session() const;
|
||||
[[nodiscard]] not_null<History*> history() const;
|
||||
|
||||
void send(Api::MessageToSend message, Api::SendOptions options);
|
||||
|
||||
void uploadFile(const QByteArray &fileContent, SendMediaType type);
|
||||
bool confirmSendingFiles(
|
||||
QImage &&image,
|
||||
|
|
Loading…
Add table
Reference in a new issue