mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-14 13:17:08 +02:00
Allow editing of collapsed quotes.
This commit is contained in:
parent
5e8c3fb146
commit
ec40292cbf
6 changed files with 37 additions and 16 deletions
|
@ -11,6 +11,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "base/event_filter.h"
|
||||
#include "chat_helpers/tabbed_panel.h"
|
||||
#include "chat_helpers/tabbed_selector.h"
|
||||
#include "core/ui_integration.h"
|
||||
#include "data/data_channel.h"
|
||||
#include "data/data_chat.h"
|
||||
#include "data/data_document.h"
|
||||
|
@ -351,8 +352,8 @@ object_ptr<Ui::RpWidget> AddReactionsSelector(
|
|||
const auto customEmojiPaused = [controller = args.controller] {
|
||||
return controller->isGifPausedAtLeastFor(PauseReason::Layer);
|
||||
};
|
||||
raw->setCustomEmojiFactory([=](QStringView data, Fn<void()> update)
|
||||
-> std::unique_ptr<Ui::Text::CustomEmoji> {
|
||||
auto factory = [=](QStringView data, Fn<void()> update)
|
||||
-> std::unique_ptr<Ui::Text::CustomEmoji> {
|
||||
const auto id = Data::ParseCustomEmojiData(data);
|
||||
auto result = owner->customEmojiManager().create(
|
||||
data,
|
||||
|
@ -364,7 +365,13 @@ object_ptr<Ui::RpWidget> AddReactionsSelector(
|
|||
}
|
||||
using namespace Ui::Text;
|
||||
return std::make_unique<FirstFrameEmoji>(std::move(result));
|
||||
}, std::move(customEmojiPaused));
|
||||
};
|
||||
raw->setCustomTextContext([=](Fn<void()> repaint) {
|
||||
return std::any(Core::MarkedTextContext{
|
||||
.session = session,
|
||||
.customEmojiRepaint = std::move(repaint),
|
||||
});
|
||||
}, customEmojiPaused, customEmojiPaused, std::move(factory));
|
||||
|
||||
const auto callback = args.callback;
|
||||
const auto isCustom = [=](DocumentId id) {
|
||||
|
|
|
@ -20,6 +20,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "core/shortcuts.h"
|
||||
#include "core/application.h"
|
||||
#include "core/core_settings.h"
|
||||
#include "core/ui_integration.h"
|
||||
#include "ui/text/text_utilities.h"
|
||||
#include "ui/toast/toast.h"
|
||||
#include "ui/wrap/vertical_layout.h"
|
||||
|
@ -322,15 +323,24 @@ TextWithTags PrepareEditText(not_null<HistoryItem*> item) {
|
|||
|
||||
bool EditTextChanged(
|
||||
not_null<HistoryItem*> item,
|
||||
const TextWithTags &updated) {
|
||||
TextWithTags updated) {
|
||||
const auto original = PrepareEditText(item);
|
||||
|
||||
auto originalWithEntities = TextWithEntities{
|
||||
std::move(original.text),
|
||||
TextUtilities::ConvertTextTagsToEntities(original.tags)
|
||||
};
|
||||
auto updatedWithEntities = TextWithEntities{
|
||||
std::move(updated.text),
|
||||
TextUtilities::ConvertTextTagsToEntities(updated.tags)
|
||||
};
|
||||
TextUtilities::PrepareForSending(originalWithEntities, 0);
|
||||
TextUtilities::PrepareForSending(updatedWithEntities, 0);
|
||||
|
||||
// Tags can be different for the same entities, because for
|
||||
// animated emoji each tag contains a different random number.
|
||||
// So we compare entities instead of tags.
|
||||
return (original.text != updated.text)
|
||||
|| (TextUtilities::ConvertTextTagsToEntities(original.tags)
|
||||
!= TextUtilities::ConvertTextTagsToEntities(updated.tags));
|
||||
return originalWithEntities != updatedWithEntities;
|
||||
}
|
||||
|
||||
Fn<bool(
|
||||
|
@ -384,12 +394,16 @@ void InitMessageFieldHandlers(
|
|||
const style::InputField *fieldStyle) {
|
||||
field->setTagMimeProcessor(
|
||||
FieldTagMimeProcessor(session, allowPremiumEmoji));
|
||||
const auto paused = [customEmojiPaused] {
|
||||
field->setCustomTextContext([=](Fn<void()> repaint) {
|
||||
return std::any(Core::MarkedTextContext{
|
||||
.session = session,
|
||||
.customEmojiRepaint = std::move(repaint),
|
||||
});
|
||||
}, [customEmojiPaused] {
|
||||
return On(PowerSaving::kEmojiChat) || customEmojiPaused();
|
||||
};
|
||||
field->setCustomEmojiFactory(
|
||||
session->data().customEmojiManager().factory(),
|
||||
std::move(customEmojiPaused));
|
||||
}, [customEmojiPaused] {
|
||||
return On(PowerSaving::kChatSpoiler) || customEmojiPaused();
|
||||
});
|
||||
field->setInstantReplaces(Ui::InstantReplaces::Default());
|
||||
field->setInstantReplacesEnabled(
|
||||
Core::App().settings().replaceEmojiValue());
|
||||
|
|
|
@ -42,7 +42,7 @@ class Show;
|
|||
[[nodiscard]] TextWithTags PrepareEditText(not_null<HistoryItem*> item);
|
||||
[[nodiscard]] bool EditTextChanged(
|
||||
not_null<HistoryItem*> item,
|
||||
const TextWithTags &updated);
|
||||
TextWithTags updated);
|
||||
|
||||
Fn<bool(
|
||||
Ui::InputField::EditLinkSelection selection,
|
||||
|
|
|
@ -271,7 +271,7 @@ bool UiIntegration::copyPreOnClick(const QVariant &context) {
|
|||
}
|
||||
|
||||
std::unique_ptr<Ui::Text::CustomEmoji> UiIntegration::createCustomEmoji(
|
||||
const QString &data,
|
||||
QStringView data,
|
||||
const std::any &context) {
|
||||
const auto my = std::any_cast<MarkedTextContext>(&context);
|
||||
if (!my || !my->session) {
|
||||
|
|
|
@ -58,7 +58,7 @@ public:
|
|||
const Ui::Emoji::One *defaultEmojiVariant(
|
||||
const Ui::Emoji::One *emoji) override;
|
||||
std::unique_ptr<Ui::Text::CustomEmoji> createCustomEmoji(
|
||||
const QString &data,
|
||||
QStringView data,
|
||||
const std::any &context) override;
|
||||
Fn<void()> createSpoilerRepaint(const std::any &context) override;
|
||||
bool allowClickHandlerActivation(
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 20caa93a8d2b5b279f36eb19d9200be071420ba3
|
||||
Subproject commit 29bce3f8ff693e0386617dfd550a225d0ff11c5d
|
Loading…
Add table
Reference in a new issue