mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-16 14:17:12 +02:00
Added spoiler support to service messages.
This commit is contained in:
parent
1d2065e4ef
commit
8b74dc2dec
6 changed files with 17 additions and 19 deletions
|
@ -1619,7 +1619,7 @@ void HistoryMessage::setText(const TextWithEntities &textWithEntities) {
|
|||
withLocalEntities(textWithEntities),
|
||||
Ui::ItemTextOptions(this),
|
||||
context);
|
||||
HistoryView::FillTextWithAnimatedSpoilers(_text, textWithEntities);
|
||||
HistoryView::FillTextWithAnimatedSpoilers(_text);
|
||||
if (!textWithEntities.text.isEmpty() && _text.isEmpty()) {
|
||||
// If server has allowed some text that we've trim-ed entirely,
|
||||
// just replace it with something so that UI won't look buggy.
|
||||
|
|
|
@ -18,6 +18,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "history/history_item_components.h"
|
||||
#include "history/view/history_view_service_message.h"
|
||||
#include "history/view/history_view_item_preview.h"
|
||||
#include "history/view/history_view_spoiler_click_handler.h"
|
||||
#include "data/data_folder.h"
|
||||
#include "data/data_session.h"
|
||||
#include "data/data_media_types.h"
|
||||
|
@ -695,7 +696,8 @@ HistoryService::PreparedText HistoryService::preparePinnedText() {
|
|||
result.links.push_back(fromLink());
|
||||
result.links.push_back(pinned->lnk);
|
||||
if (mediaText.isEmpty()) {
|
||||
auto original = pinned->msg->originalText().text;
|
||||
auto original = TextUtilities::TextWithSpoilerCommands(
|
||||
pinned->msg->originalText());
|
||||
auto cutAt = 0;
|
||||
auto limit = kPinnedMessageTextLimit;
|
||||
auto size = original.size();
|
||||
|
@ -946,7 +948,9 @@ ItemPreview HistoryService::toPreview(ToPreviewOptions options) const {
|
|||
// Because larger version is shown exactly to the left of the preview.
|
||||
//auto media = _media ? _media->toPreview(options) : ItemPreview();
|
||||
return {
|
||||
.text = textcmdLink(1, TextUtilities::Clean(notificationText())),
|
||||
.text = textcmdLink(
|
||||
1,
|
||||
TextUtilities::Clean(notificationText(), true)),
|
||||
//.images = std::move(media.images),
|
||||
//.loadingContext = std::move(media.loadingContext),
|
||||
};
|
||||
|
@ -980,6 +984,7 @@ void HistoryService::setServiceText(const PreparedText &prepared) {
|
|||
st::serviceTextStyle,
|
||||
prepared.text,
|
||||
Ui::ItemTextServiceOptions());
|
||||
HistoryView::FillTextWithAnimatedSpoilers(_text);
|
||||
auto linkIndex = 0;
|
||||
for (const auto &link : prepared.links) {
|
||||
// Link indices start with 1.
|
||||
|
|
|
@ -38,15 +38,11 @@ void AnimatedSpoilerClickHandler::onClick(ClickContext context) const {
|
|||
|
||||
} // namespace
|
||||
|
||||
void FillTextWithAnimatedSpoilers(
|
||||
Ui::Text::String &text,
|
||||
const TextWithEntities &textWithEntities) {
|
||||
for (auto i = 0; i < textWithEntities.entities.size(); i++) {
|
||||
if (textWithEntities.entities[i].type() == EntityType::Spoiler) {
|
||||
text.setSpoiler(
|
||||
i + 1,
|
||||
std::make_shared<AnimatedSpoilerClickHandler>());
|
||||
}
|
||||
void FillTextWithAnimatedSpoilers(Ui::Text::String &text) {
|
||||
for (auto i = 0; i < text.spoilersCount(); i++) {
|
||||
text.setSpoiler(
|
||||
i + 1,
|
||||
std::make_shared<AnimatedSpoilerClickHandler>());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -9,8 +9,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
|
||||
namespace HistoryView {
|
||||
|
||||
void FillTextWithAnimatedSpoilers(
|
||||
Ui::Text::String &text,
|
||||
const TextWithEntities &textWithEntities);
|
||||
void FillTextWithAnimatedSpoilers(Ui::Text::String &text);
|
||||
|
||||
} // namespace HistoryView
|
||||
|
|
|
@ -197,13 +197,12 @@ Ui::Text::String Media::createCaption(not_null<HistoryItem*> item) const {
|
|||
const auto context = Core::MarkedTextContext{
|
||||
.session = &history()->session()
|
||||
};
|
||||
const auto textWithEntities = item->originalTextWithLocalEntities();
|
||||
result.setMarkedText(
|
||||
st::messageTextStyle,
|
||||
textWithEntities,
|
||||
item->originalTextWithLocalEntities(),
|
||||
Ui::ItemTextOptions(item),
|
||||
context);
|
||||
FillTextWithAnimatedSpoilers(result, textWithEntities);
|
||||
FillTextWithAnimatedSpoilers(result);
|
||||
if (const auto width = _parent->skipBlockWidth()) {
|
||||
result.updateSkipBlock(width, _parent->skipBlockHeight());
|
||||
}
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit db871a87f5a2895b6ffdca106ecdff6f710e2b02
|
||||
Subproject commit 44853e933400a7f1536b9847fd0adc2b7d575bff
|
Loading…
Add table
Reference in a new issue