mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Removed redundant code for old sponsored messages.
This commit is contained in:
parent
0da515abc5
commit
fc86bb7a5f
9 changed files with 4 additions and 125 deletions
|
@ -311,6 +311,8 @@ enum class MessageFlag : uint64 {
|
||||||
DisplayFromChecked = (1ULL << 40),
|
DisplayFromChecked = (1ULL << 40),
|
||||||
|
|
||||||
ShowSimilarChannels = (1ULL << 41),
|
ShowSimilarChannels = (1ULL << 41),
|
||||||
|
|
||||||
|
Sponsored = (1ULL << 42),
|
||||||
};
|
};
|
||||||
inline constexpr bool is_flag_type(MessageFlag) { return true; }
|
inline constexpr bool is_flag_type(MessageFlag) { return true; }
|
||||||
using MessageFlags = base::flags<MessageFlag>;
|
using MessageFlags = base::flags<MessageFlag>;
|
||||||
|
|
|
@ -853,8 +853,6 @@ bool HistoryInner::canHaveFromUserpics() const {
|
||||||
&& !_peer->isRepliesChat()
|
&& !_peer->isRepliesChat()
|
||||||
&& !_isChatWide) {
|
&& !_isChatWide) {
|
||||||
return false;
|
return false;
|
||||||
} else if (_canHaveFromUserpicsSponsored) {
|
|
||||||
return true;
|
|
||||||
} else if (_peer->isChannel() && !_peer->isMegagroup()) {
|
} else if (_peer->isChannel() && !_peer->isMegagroup()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -4049,10 +4047,6 @@ void HistoryInner::clearChooseReportReason() {
|
||||||
_chooseForReportReason = std::nullopt;
|
_chooseForReportReason = std::nullopt;
|
||||||
}
|
}
|
||||||
|
|
||||||
void HistoryInner::setCanHaveFromUserpicsSponsored(bool value) {
|
|
||||||
_canHaveFromUserpicsSponsored = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto HistoryInner::viewByItem(const HistoryItem *item) const -> Element* {
|
auto HistoryInner::viewByItem(const HistoryItem *item) const -> Element* {
|
||||||
return !item
|
return !item
|
||||||
? nullptr
|
? nullptr
|
||||||
|
|
|
@ -183,8 +183,6 @@ public:
|
||||||
void setChooseReportReason(Ui::ReportReason reason);
|
void setChooseReportReason(Ui::ReportReason reason);
|
||||||
void clearChooseReportReason();
|
void clearChooseReportReason();
|
||||||
|
|
||||||
void setCanHaveFromUserpicsSponsored(bool value);
|
|
||||||
|
|
||||||
// -1 if should not be visible, -2 if bad history()
|
// -1 if should not be visible, -2 if bad history()
|
||||||
[[nodiscard]] int itemTop(const HistoryItem *item) const;
|
[[nodiscard]] int itemTop(const HistoryItem *item) const;
|
||||||
[[nodiscard]] int itemTop(const Element *view) const;
|
[[nodiscard]] int itemTop(const Element *view) const;
|
||||||
|
@ -490,7 +488,6 @@ private:
|
||||||
bool _pressWasInactive = false;
|
bool _pressWasInactive = false;
|
||||||
bool _recountedAfterPendingResizedItems = false;
|
bool _recountedAfterPendingResizedItems = false;
|
||||||
bool _useCornerReaction = false;
|
bool _useCornerReaction = false;
|
||||||
bool _canHaveFromUserpicsSponsored = false;
|
|
||||||
bool _acceptsHorizontalScroll = false;
|
bool _acceptsHorizontalScroll = false;
|
||||||
bool _horizontalScrollLocked = false;
|
bool _horizontalScrollLocked = false;
|
||||||
|
|
||||||
|
|
|
@ -731,7 +731,6 @@ HistoryItem::HistoryItem(
|
||||||
webpage,
|
webpage,
|
||||||
MediaWebPageFlag::Sponsored);
|
MediaWebPageFlag::Sponsored);
|
||||||
_media = std::move(webpageMedia);
|
_media = std::move(webpageMedia);
|
||||||
setSponsoredFrom(from);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
HistoryItem::HistoryItem(
|
HistoryItem::HistoryItem(
|
||||||
|
@ -1181,10 +1180,6 @@ HistoryItem *HistoryItem::lookupDiscussionPostOriginal() const {
|
||||||
PeerData *HistoryItem::computeDisplayFrom() const {
|
PeerData *HistoryItem::computeDisplayFrom() const {
|
||||||
if (const auto sender = discussionPostOriginalSender()) {
|
if (const auto sender = discussionPostOriginalSender()) {
|
||||||
return sender;
|
return sender;
|
||||||
} else if (const auto sponsored = Get<HistoryMessageSponsored>()) {
|
|
||||||
if (sponsored->sender) {
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
} else if (const auto forwarded = Get<HistoryMessageForwarded>()) {
|
} else if (const auto forwarded = Get<HistoryMessageForwarded>()) {
|
||||||
if (_history->peer->isSelf()
|
if (_history->peer->isSelf()
|
||||||
|| _history->peer->isRepliesChat()
|
|| _history->peer->isRepliesChat()
|
||||||
|
@ -1492,7 +1487,7 @@ bool HistoryItem::isScheduled() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool HistoryItem::isSponsored() const {
|
bool HistoryItem::isSponsored() const {
|
||||||
return Has<HistoryMessageSponsored>();
|
return _flags & MessageFlag::Sponsored;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool HistoryItem::skipNotification() const {
|
bool HistoryItem::skipNotification() const {
|
||||||
|
@ -2486,9 +2481,7 @@ PeerData *HistoryItem::originalSender() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
const HiddenSenderInfo *HistoryItem::hiddenSenderInfo() const {
|
const HiddenSenderInfo *HistoryItem::hiddenSenderInfo() const {
|
||||||
if (const auto sponsored = Get<HistoryMessageSponsored>()) {
|
if (const auto forwarded = Get<HistoryMessageForwarded>()) {
|
||||||
return sponsored->sender.get();
|
|
||||||
} else if (const auto forwarded = Get<HistoryMessageForwarded>()) {
|
|
||||||
return forwarded->hiddenSenderInfo.get();
|
return forwarded->hiddenSenderInfo.get();
|
||||||
}
|
}
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
@ -3100,8 +3093,6 @@ ItemPreview HistoryItem::toPreview(ToPreviewOptions options) const {
|
||||||
const auto sender = [&]() -> std::optional<QString> {
|
const auto sender = [&]() -> std::optional<QString> {
|
||||||
if (options.hideSender || isPost() || isEmpty()) {
|
if (options.hideSender || isPost() || isEmpty()) {
|
||||||
return {};
|
return {};
|
||||||
} else if (const auto sponsored = Get<HistoryMessageSponsored>()) {
|
|
||||||
return sponsored->sender->name;
|
|
||||||
} else if (!_history->peer->isUser()) {
|
} else if (!_history->peer->isUser()) {
|
||||||
if (const auto from = displayFrom()) {
|
if (const auto from = displayFrom()) {
|
||||||
return fromSender(from);
|
return fromSender(from);
|
||||||
|
@ -3349,36 +3340,6 @@ TextWithEntities HistoryItem::withLocalEntities(
|
||||||
return textWithEntities;
|
return textWithEntities;
|
||||||
}
|
}
|
||||||
|
|
||||||
void HistoryItem::setSponsoredFrom(const Data::SponsoredFrom &from) {
|
|
||||||
AddComponents(HistoryMessageSponsored::Bit());
|
|
||||||
const auto sponsored = Get<HistoryMessageSponsored>();
|
|
||||||
sponsored->sender = std::make_unique<HiddenSenderInfo>(
|
|
||||||
from.title,
|
|
||||||
false,
|
|
||||||
from.peer ? from.peer->colorIndex() : std::optional<uint8>());
|
|
||||||
sponsored->recommended = from.isRecommended;
|
|
||||||
sponsored->isForceUserpicDisplay = from.isForceUserpicDisplay;
|
|
||||||
if (from.userpic.location.valid()) {
|
|
||||||
sponsored->sender->customUserpic.set(
|
|
||||||
&_history->session(),
|
|
||||||
from.userpic);
|
|
||||||
}
|
|
||||||
|
|
||||||
sponsored->externalLink = from.externalLink;
|
|
||||||
using Type = HistoryMessageSponsored::Type;
|
|
||||||
sponsored->type = (!from.externalLink.isEmpty())
|
|
||||||
? Type::ExternalLink
|
|
||||||
: from.isExactPost
|
|
||||||
? Type::Post
|
|
||||||
: from.isBot
|
|
||||||
? Type::Bot
|
|
||||||
: from.isBroadcast
|
|
||||||
? Type::Broadcast
|
|
||||||
: (from.peer && from.peer->isUser())
|
|
||||||
? Type::User
|
|
||||||
: Type::Group;
|
|
||||||
}
|
|
||||||
|
|
||||||
void HistoryItem::createComponentsHelper(
|
void HistoryItem::createComponentsHelper(
|
||||||
MessageFlags flags,
|
MessageFlags flags,
|
||||||
FullReplyTo replyTo,
|
FullReplyTo replyTo,
|
||||||
|
|
|
@ -615,8 +615,6 @@ private:
|
||||||
// It should show the receipt for the payed invoice. Still let mobile apps do that.
|
// It should show the receipt for the payed invoice. Still let mobile apps do that.
|
||||||
void replaceBuyWithReceiptInMarkup();
|
void replaceBuyWithReceiptInMarkup();
|
||||||
|
|
||||||
void setSponsoredFrom(const Data::SponsoredFrom &from);
|
|
||||||
|
|
||||||
[[nodiscard]] PreparedServiceText preparePinnedText();
|
[[nodiscard]] PreparedServiceText preparePinnedText();
|
||||||
[[nodiscard]] PreparedServiceText prepareGameScoreText();
|
[[nodiscard]] PreparedServiceText prepareGameScoreText();
|
||||||
[[nodiscard]] PreparedServiceText preparePaymentSentText();
|
[[nodiscard]] PreparedServiceText preparePaymentSentText();
|
||||||
|
|
|
@ -140,22 +140,6 @@ struct HistoryMessageForwarded : public RuntimeComponent<HistoryMessageForwarded
|
||||||
bool story = false;
|
bool story = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct HistoryMessageSponsored : public RuntimeComponent<HistoryMessageSponsored, HistoryItem> {
|
|
||||||
enum class Type : uchar {
|
|
||||||
User,
|
|
||||||
Group,
|
|
||||||
Broadcast,
|
|
||||||
Post,
|
|
||||||
Bot,
|
|
||||||
ExternalLink,
|
|
||||||
};
|
|
||||||
std::unique_ptr<HiddenSenderInfo> sender;
|
|
||||||
Type type = Type::User;
|
|
||||||
bool recommended = false;
|
|
||||||
bool isForceUserpicDisplay = false;
|
|
||||||
QString externalLink;
|
|
||||||
};
|
|
||||||
|
|
||||||
class ReplyToMessagePointer final {
|
class ReplyToMessagePointer final {
|
||||||
public:
|
public:
|
||||||
ReplyToMessagePointer(HistoryItem *item = nullptr) : _data(item) {
|
ReplyToMessagePointer(HistoryItem *item = nullptr) : _data(item) {
|
||||||
|
|
|
@ -294,9 +294,6 @@ HistoryWidget::HistoryWidget(
|
||||||
if (_history
|
if (_history
|
||||||
&& _history->loadedAtBottom()
|
&& _history->loadedAtBottom()
|
||||||
&& session().data().sponsoredMessages().append(_history)) {
|
&& session().data().sponsoredMessages().append(_history)) {
|
||||||
if (_list) {
|
|
||||||
_list->setCanHaveFromUserpicsSponsored(true);
|
|
||||||
}
|
|
||||||
_scroll->contentAdded();
|
_scroll->contentAdded();
|
||||||
}
|
}
|
||||||
}, lifetime());
|
}, lifetime());
|
||||||
|
@ -2347,9 +2344,6 @@ void HistoryWidget::showHistory(
|
||||||
_scroll->setTrackingContent(
|
_scroll->setTrackingContent(
|
||||||
sponsored.canHaveFor(_history));
|
sponsored.canHaveFor(_history));
|
||||||
} else if (state == State::InjectToMiddle) {
|
} else if (state == State::InjectToMiddle) {
|
||||||
if (_list) {
|
|
||||||
_list->setCanHaveFromUserpicsSponsored(true);
|
|
||||||
}
|
|
||||||
injectSponsoredMessages();
|
injectSponsoredMessages();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -11,7 +11,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "history/history.h"
|
#include "history/history.h"
|
||||||
#include "history/history_item_components.h"
|
#include "history/history_item_components.h"
|
||||||
#include "history/view/history_view_cursor_state.h"
|
#include "history/view/history_view_cursor_state.h"
|
||||||
#include "history/view/history_view_sponsored_click_handler.h"
|
|
||||||
#include "lang/lang_keys.h"
|
#include "lang/lang_keys.h"
|
||||||
#include "ui/effects/ripple_animation.h"
|
#include "ui/effects/ripple_animation.h"
|
||||||
#include "ui/painter.h"
|
#include "ui/painter.h"
|
||||||
|
@ -22,24 +21,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
namespace HistoryView {
|
namespace HistoryView {
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
using SponsoredType = HistoryMessageSponsored::Type;
|
|
||||||
|
|
||||||
inline auto SponsoredPhrase(SponsoredType type) {
|
|
||||||
const auto phrase = [&] {
|
|
||||||
switch (type) {
|
|
||||||
case SponsoredType::User: return tr::lng_view_button_user;
|
|
||||||
case SponsoredType::Group: return tr::lng_view_button_group;
|
|
||||||
case SponsoredType::Broadcast: return tr::lng_view_button_channel;
|
|
||||||
case SponsoredType::Post: return tr::lng_view_button_message;
|
|
||||||
case SponsoredType::Bot: return tr::lng_view_button_bot;
|
|
||||||
case SponsoredType::ExternalLink:
|
|
||||||
return tr::lng_view_button_external_link;
|
|
||||||
}
|
|
||||||
Unexpected("SponsoredType in SponsoredPhrase.");
|
|
||||||
}();
|
|
||||||
return Ui::Text::Upper(phrase(tr::now));
|
|
||||||
}
|
|
||||||
|
|
||||||
[[nodiscard]] ClickHandlerPtr MakeMediaButtonClickHandler(
|
[[nodiscard]] ClickHandlerPtr MakeMediaButtonClickHandler(
|
||||||
not_null<Data::Media*> media) {
|
not_null<Data::Media*> media) {
|
||||||
const auto giveaway = media->giveaway();
|
const auto giveaway = media->giveaway();
|
||||||
|
@ -70,10 +51,6 @@ inline auto SponsoredPhrase(SponsoredType type) {
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
struct ViewButton::Inner {
|
struct ViewButton::Inner {
|
||||||
Inner(
|
|
||||||
not_null<HistoryMessageSponsored*> sponsored,
|
|
||||||
uint8 colorIndex,
|
|
||||||
Fn<void()> updateCallback);
|
|
||||||
Inner(
|
Inner(
|
||||||
not_null<Data::Media*> media,
|
not_null<Data::Media*> media,
|
||||||
uint8 colorIndex,
|
uint8 colorIndex,
|
||||||
|
@ -98,18 +75,6 @@ bool ViewButton::MediaHasViewButton(not_null<Data::Media*> media) {
|
||||||
return (media->giveaway() != nullptr);
|
return (media->giveaway() != nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
ViewButton::Inner::Inner(
|
|
||||||
not_null<HistoryMessageSponsored*> sponsored,
|
|
||||||
uint8 colorIndex,
|
|
||||||
Fn<void()> updateCallback)
|
|
||||||
: margins(st::historyViewButtonMargins)
|
|
||||||
, link(SponsoredLink(sponsored->externalLink))
|
|
||||||
, updateCallback(std::move(updateCallback))
|
|
||||||
, colorIndex(colorIndex)
|
|
||||||
, externalLink((sponsored->type == SponsoredType::ExternalLink) ? 1 : 0)
|
|
||||||
, text(st::historyViewButtonTextStyle, SponsoredPhrase(sponsored->type)) {
|
|
||||||
}
|
|
||||||
|
|
||||||
ViewButton::Inner::Inner(
|
ViewButton::Inner::Inner(
|
||||||
not_null<Data::Media*> media,
|
not_null<Data::Media*> media,
|
||||||
uint8 colorIndex,
|
uint8 colorIndex,
|
||||||
|
@ -141,16 +106,6 @@ void ViewButton::Inner::toggleRipple(bool pressed) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ViewButton::ViewButton(
|
|
||||||
not_null<HistoryMessageSponsored*> sponsored,
|
|
||||||
uint8 colorIndex,
|
|
||||||
Fn<void()> updateCallback)
|
|
||||||
: _inner(std::make_unique<Inner>(
|
|
||||||
sponsored,
|
|
||||||
colorIndex,
|
|
||||||
std::move(updateCallback))) {
|
|
||||||
}
|
|
||||||
|
|
||||||
ViewButton::ViewButton(
|
ViewButton::ViewButton(
|
||||||
not_null<Data::Media*> media,
|
not_null<Data::Media*> media,
|
||||||
uint8 colorIndex,
|
uint8 colorIndex,
|
||||||
|
|
|
@ -9,8 +9,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
|
|
||||||
#include "ui/chat/chat_style.h"
|
#include "ui/chat/chat_style.h"
|
||||||
|
|
||||||
struct HistoryMessageSponsored;
|
|
||||||
|
|
||||||
namespace Data {
|
namespace Data {
|
||||||
class Media;
|
class Media;
|
||||||
} // namespace Data
|
} // namespace Data
|
||||||
|
@ -23,10 +21,6 @@ struct TextState;
|
||||||
|
|
||||||
class ViewButton {
|
class ViewButton {
|
||||||
public:
|
public:
|
||||||
ViewButton(
|
|
||||||
not_null<HistoryMessageSponsored*> sponsored,
|
|
||||||
uint8 colorIndex,
|
|
||||||
Fn<void()> updateCallback);
|
|
||||||
ViewButton(
|
ViewButton(
|
||||||
not_null<Data::Media*> media,
|
not_null<Data::Media*> media,
|
||||||
uint8 colorIndex,
|
uint8 colorIndex,
|
||||||
|
|
Loading…
Add table
Reference in a new issue