mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
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:
parent
f58171b50b
commit
61f4defa4d
4 changed files with 29 additions and 29 deletions
|
@ -1995,11 +1995,18 @@ MediaStory::MediaStory(
|
||||||
owner->registerStoryItem(storyId, parent);
|
owner->registerStoryItem(storyId, parent);
|
||||||
|
|
||||||
const auto stories = &owner->stories();
|
const auto stories = &owner->stories();
|
||||||
const auto maybeStory = stories->lookup(storyId);
|
if (const auto maybeStory = stories->lookup(storyId)) {
|
||||||
if (!maybeStory) {
|
if (!_mention) {
|
||||||
|
parent->setText((*maybeStory)->caption());
|
||||||
|
}
|
||||||
|
} else {
|
||||||
if (maybeStory.error() == NoStory::Unknown) {
|
if (maybeStory.error() == NoStory::Unknown) {
|
||||||
stories->resolve(storyId, crl::guard(this, [=] {
|
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;
|
_expired = true;
|
||||||
}
|
}
|
||||||
if (_mention) {
|
if (_mention) {
|
||||||
|
@ -2051,7 +2058,9 @@ TextWithEntities MediaStory::notificationText() const {
|
||||||
&& maybeStory.error() == Data::NoStory::Deleted))
|
&& maybeStory.error() == Data::NoStory::Deleted))
|
||||||
? tr::lng_in_dlg_story_expired
|
? tr::lng_in_dlg_story_expired
|
||||||
: tr::lng_in_dlg_story)(tr::now),
|
: tr::lng_in_dlg_story)(tr::now),
|
||||||
parent()->originalText());
|
(maybeStory
|
||||||
|
? (*maybeStory)->caption()
|
||||||
|
: TextWithEntities()));
|
||||||
}
|
}
|
||||||
|
|
||||||
QString MediaStory::pinnedTextSubstring() const {
|
QString MediaStory::pinnedTextSubstring() const {
|
||||||
|
@ -2091,6 +2100,9 @@ std::unique_ptr<HistoryView::Media> MediaStory::createView(
|
||||||
const auto stories = &parent()->history()->owner().stories();
|
const auto stories = &parent()->history()->owner().stories();
|
||||||
const auto maybeStory = stories->lookup(_storyId);
|
const auto maybeStory = stories->lookup(_storyId);
|
||||||
if (!maybeStory) {
|
if (!maybeStory) {
|
||||||
|
if (!_mention) {
|
||||||
|
realParent->setText(TextWithEntities());
|
||||||
|
}
|
||||||
if (maybeStory.error() == Data::NoStory::Deleted) {
|
if (maybeStory.error() == Data::NoStory::Deleted) {
|
||||||
_expired = true;
|
_expired = true;
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
@ -2112,6 +2124,7 @@ std::unique_ptr<HistoryView::Media> MediaStory::createView(
|
||||||
message,
|
message,
|
||||||
std::make_unique<HistoryView::StoryMention>(message, story));
|
std::make_unique<HistoryView::StoryMention>(message, story));
|
||||||
} else {
|
} else {
|
||||||
|
realParent->setText(story->caption());
|
||||||
if (const auto photo = story->photo()) {
|
if (const auto photo = story->photo()) {
|
||||||
return std::make_unique<HistoryView::Photo>(
|
return std::make_unique<HistoryView::Photo>(
|
||||||
message,
|
message,
|
||||||
|
|
|
@ -846,12 +846,8 @@ void Element::validateText() {
|
||||||
_media = nullptr;
|
_media = nullptr;
|
||||||
if (!storyMention) {
|
if (!storyMention) {
|
||||||
if (_text.isEmpty()) {
|
if (_text.isEmpty()) {
|
||||||
auto now = Ui::Text::Italic(
|
setTextWithLinks(Ui::Text::Italic(
|
||||||
tr::lng_forwarded_story_expired(tr::now));
|
tr::lng_forwarded_story_expired(tr::now)));
|
||||||
if (!text.empty()) {
|
|
||||||
now.append(u"\n\n"_q).append(text);
|
|
||||||
}
|
|
||||||
setTextWithLinks(std::move(now));
|
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,7 +64,7 @@ namespace {
|
||||||
|
|
||||||
constexpr auto kPhotoProgressInterval = crl::time(100);
|
constexpr auto kPhotoProgressInterval = crl::time(100);
|
||||||
constexpr auto kPhotoDuration = 5 * crl::time(1000);
|
constexpr auto kPhotoDuration = 5 * crl::time(1000);
|
||||||
constexpr auto kFullContentFade = 0.35;
|
constexpr auto kFullContentFade = 0.6;
|
||||||
constexpr auto kSiblingMultiplierDefault = 0.448;
|
constexpr auto kSiblingMultiplierDefault = 0.448;
|
||||||
constexpr auto kSiblingMultiplierMax = 0.72;
|
constexpr auto kSiblingMultiplierMax = 0.72;
|
||||||
constexpr auto kSiblingOutsidePart = 0.24;
|
constexpr auto kSiblingOutsidePart = 0.24;
|
||||||
|
|
|
@ -8,7 +8,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "media/stories/media_stories_share.h"
|
#include "media/stories/media_stories_share.h"
|
||||||
|
|
||||||
#include "api/api_common.h"
|
#include "api/api_common.h"
|
||||||
#include "api/api_text_entities.h"
|
|
||||||
#include "apiwrap.h"
|
#include "apiwrap.h"
|
||||||
#include "base/random.h"
|
#include "base/random.h"
|
||||||
#include "boxes/share_box.h"
|
#include "boxes/share_box.h"
|
||||||
|
@ -87,7 +86,7 @@ namespace Media::Stories {
|
||||||
for (const auto thread : result) {
|
for (const auto thread : result) {
|
||||||
const auto error = GetErrorTextForSending(
|
const auto error = GetErrorTextForSending(
|
||||||
thread,
|
thread,
|
||||||
{ .story = story });
|
{ .story = story, .text = &comment });
|
||||||
if (!error.isEmpty()) {
|
if (!error.isEmpty()) {
|
||||||
return std::make_pair(error, thread);
|
return std::make_pair(error, thread);
|
||||||
}
|
}
|
||||||
|
@ -106,21 +105,16 @@ namespace Media::Stories {
|
||||||
return;
|
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();
|
const auto api = &story->owner().session().api();
|
||||||
auto &histories = story->owner().histories();
|
auto &histories = story->owner().histories();
|
||||||
for (const auto thread : result) {
|
for (const auto thread : result) {
|
||||||
const auto action = Api::SendAction(thread, options);
|
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 peer = thread->peer();
|
||||||
const auto threadHistory = thread->owningHistory();
|
const auto threadHistory = thread->owningHistory();
|
||||||
const auto randomId = base::RandomValue<uint64>();
|
const auto randomId = base::RandomValue<uint64>();
|
||||||
|
@ -132,9 +126,6 @@ namespace Media::Stories {
|
||||||
if (silentPost) {
|
if (silentPost) {
|
||||||
sendFlags |= MTPmessages_SendMedia::Flag::f_silent;
|
sendFlags |= MTPmessages_SendMedia::Flag::f_silent;
|
||||||
}
|
}
|
||||||
if (!sentEntities.v.isEmpty()) {
|
|
||||||
sendFlags |= MTPmessages_SendMedia::Flag::f_entities;
|
|
||||||
}
|
|
||||||
const auto done = [=] {
|
const auto done = [=] {
|
||||||
if (!--state->requests) {
|
if (!--state->requests) {
|
||||||
if (show->valid()) {
|
if (show->valid()) {
|
||||||
|
@ -154,10 +145,10 @@ namespace Media::Stories {
|
||||||
MTP_inputMediaStory(
|
MTP_inputMediaStory(
|
||||||
user->inputUser,
|
user->inputUser,
|
||||||
MTP_int(id.story)),
|
MTP_int(id.story)),
|
||||||
MTP_string(captionText),
|
MTPstring(),
|
||||||
MTP_long(randomId),
|
MTP_long(randomId),
|
||||||
MTPReplyMarkup(),
|
MTPReplyMarkup(),
|
||||||
sentEntities,
|
MTPVector<MTPMessageEntity>(),
|
||||||
MTP_int(action.options.scheduled),
|
MTP_int(action.options.scheduled),
|
||||||
MTP_inputPeerEmpty()
|
MTP_inputPeerEmpty()
|
||||||
), [=](const MTPUpdates &result, const MTP::Response &response) {
|
), [=](const MTPUpdates &result, const MTP::Response &response) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue