Partially revert "Support and use share comment in stories."

Send sharing comment as a separate message, like in posts sharing.
This commit is contained in:
John Preston 2023-07-28 21:20:06 +04:00
parent f58171b50b
commit 61f4defa4d
4 changed files with 29 additions and 29 deletions

View File

@ -1995,11 +1995,18 @@ MediaStory::MediaStory(
owner->registerStoryItem(storyId, parent);
const auto stories = &owner->stories();
const auto maybeStory = stories->lookup(storyId);
if (!maybeStory) {
if (const auto maybeStory = stories->lookup(storyId)) {
if (!_mention) {
parent->setText((*maybeStory)->caption());
}
} else {
if (maybeStory.error() == NoStory::Unknown) {
stories->resolve(storyId, crl::guard(this, [=] {
if (!stories->lookup(storyId)) {
if (const auto maybeStory = stories->lookup(storyId)) {
if (!_mention) {
parent->setText((*maybeStory)->caption());
}
} else {
_expired = true;
}
if (_mention) {
@ -2051,7 +2058,9 @@ TextWithEntities MediaStory::notificationText() const {
&& maybeStory.error() == Data::NoStory::Deleted))
? tr::lng_in_dlg_story_expired
: tr::lng_in_dlg_story)(tr::now),
parent()->originalText());
(maybeStory
? (*maybeStory)->caption()
: TextWithEntities()));
}
QString MediaStory::pinnedTextSubstring() const {
@ -2091,6 +2100,9 @@ std::unique_ptr<HistoryView::Media> MediaStory::createView(
const auto stories = &parent()->history()->owner().stories();
const auto maybeStory = stories->lookup(_storyId);
if (!maybeStory) {
if (!_mention) {
realParent->setText(TextWithEntities());
}
if (maybeStory.error() == Data::NoStory::Deleted) {
_expired = true;
return nullptr;
@ -2112,6 +2124,7 @@ std::unique_ptr<HistoryView::Media> MediaStory::createView(
message,
std::make_unique<HistoryView::StoryMention>(message, story));
} else {
realParent->setText(story->caption());
if (const auto photo = story->photo()) {
return std::make_unique<HistoryView::Photo>(
message,

View File

@ -846,12 +846,8 @@ void Element::validateText() {
_media = nullptr;
if (!storyMention) {
if (_text.isEmpty()) {
auto now = Ui::Text::Italic(
tr::lng_forwarded_story_expired(tr::now));
if (!text.empty()) {
now.append(u"\n\n"_q).append(text);
}
setTextWithLinks(std::move(now));
setTextWithLinks(Ui::Text::Italic(
tr::lng_forwarded_story_expired(tr::now)));
}
return;
}

View File

@ -64,7 +64,7 @@ namespace {
constexpr auto kPhotoProgressInterval = crl::time(100);
constexpr auto kPhotoDuration = 5 * crl::time(1000);
constexpr auto kFullContentFade = 0.35;
constexpr auto kFullContentFade = 0.6;
constexpr auto kSiblingMultiplierDefault = 0.448;
constexpr auto kSiblingMultiplierMax = 0.72;
constexpr auto kSiblingOutsidePart = 0.24;

View File

@ -8,7 +8,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "media/stories/media_stories_share.h"
#include "api/api_common.h"
#include "api/api_text_entities.h"
#include "apiwrap.h"
#include "base/random.h"
#include "boxes/share_box.h"
@ -87,7 +86,7 @@ namespace Media::Stories {
for (const auto thread : result) {
const auto error = GetErrorTextForSending(
thread,
{ .story = story });
{ .story = story, .text = &comment });
if (!error.isEmpty()) {
return std::make_pair(error, thread);
}
@ -106,21 +105,16 @@ namespace Media::Stories {
return;
}
auto caption = TextWithEntities{
comment.text,
TextUtilities::ConvertTextTagsToEntities(comment.tags)
};
TextUtilities::Trim(caption);
auto sentEntities = Api::EntitiesToMTP(
session,
caption.entities,
Api::ConvertOption::SkipLocal);
const auto captionText = caption.text;
const auto api = &story->owner().session().api();
auto &histories = story->owner().histories();
for (const auto thread : result) {
const auto action = Api::SendAction(thread, options);
if (!comment.text.isEmpty()) {
auto message = Api::MessageToSend(action);
message.textWithTags = comment;
message.action.clearDraft = false;
api->sendMessage(std::move(message));
}
const auto peer = thread->peer();
const auto threadHistory = thread->owningHistory();
const auto randomId = base::RandomValue<uint64>();
@ -132,9 +126,6 @@ namespace Media::Stories {
if (silentPost) {
sendFlags |= MTPmessages_SendMedia::Flag::f_silent;
}
if (!sentEntities.v.isEmpty()) {
sendFlags |= MTPmessages_SendMedia::Flag::f_entities;
}
const auto done = [=] {
if (!--state->requests) {
if (show->valid()) {
@ -154,10 +145,10 @@ namespace Media::Stories {
MTP_inputMediaStory(
user->inputUser,
MTP_int(id.story)),
MTP_string(captionText),
MTPstring(),
MTP_long(randomId),
MTPReplyMarkup(),
sentEntities,
MTPVector<MTPMessageEntity>(),
MTP_int(action.options.scheduled),
MTP_inputPeerEmpty()
), [=](const MTPUpdates &result, const MTP::Response &response) {