mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Show description about custom chat intro.
This commit is contained in:
parent
1e1a48865f
commit
3a5b3ff3bd
9 changed files with 42 additions and 4 deletions
|
@ -1760,6 +1760,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
"lng_action_giveaway_results_none" = "No winners of the giveaway could be selected.";
|
"lng_action_giveaway_results_none" = "No winners of the giveaway could be selected.";
|
||||||
"lng_action_boost_apply#one" = "{from} boosted the group";
|
"lng_action_boost_apply#one" = "{from} boosted the group";
|
||||||
"lng_action_boost_apply#other" = "{from} boosted the group {count} times";
|
"lng_action_boost_apply#other" = "{from} boosted the group {count} times";
|
||||||
|
"lng_action_set_chat_intro" = "{from} added the message below for all empty chats. How?";
|
||||||
|
|
||||||
"lng_similar_channels_title" = "Similar channels";
|
"lng_similar_channels_title" = "Similar channels";
|
||||||
"lng_similar_channels_view_all" = "View all";
|
"lng_similar_channels_view_all" = "View all";
|
||||||
|
|
|
@ -1549,6 +1549,11 @@ void HistoryItem::setRealShortcutId(BusinessShortcutId id) {
|
||||||
_shortcutId = id;
|
_shortcutId = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void HistoryItem::setCustomServiceLink(ClickHandlerPtr link) {
|
||||||
|
AddComponents(HistoryServiceCustomLink::Bit());
|
||||||
|
Get<HistoryServiceCustomLink>()->link = std::move(link);
|
||||||
|
}
|
||||||
|
|
||||||
void HistoryItem::destroy() {
|
void HistoryItem::destroy() {
|
||||||
_history->destroyMessage(this);
|
_history->destroyMessage(this);
|
||||||
}
|
}
|
||||||
|
@ -4849,6 +4854,7 @@ void HistoryItem::setServiceMessageByAction(const MTPmessageAction &action) {
|
||||||
prepareGiveawayLaunch,
|
prepareGiveawayLaunch,
|
||||||
prepareGiveawayResults,
|
prepareGiveawayResults,
|
||||||
prepareBoostApply,
|
prepareBoostApply,
|
||||||
|
PrepareEmptyText<MTPDmessageActionRequestedPeerSentMe>,
|
||||||
PrepareErrorText<MTPDmessageActionEmpty>));
|
PrepareErrorText<MTPDmessageActionEmpty>));
|
||||||
|
|
||||||
// Additional information.
|
// Additional information.
|
||||||
|
|
|
@ -197,6 +197,7 @@ public:
|
||||||
[[nodiscard]] BusinessShortcutId shortcutId() const;
|
[[nodiscard]] BusinessShortcutId shortcutId() const;
|
||||||
[[nodiscard]] bool isBusinessShortcut() const;
|
[[nodiscard]] bool isBusinessShortcut() const;
|
||||||
void setRealShortcutId(BusinessShortcutId id);
|
void setRealShortcutId(BusinessShortcutId id);
|
||||||
|
void setCustomServiceLink(ClickHandlerPtr link);
|
||||||
|
|
||||||
void addLogEntryOriginal(
|
void addLogEntryOriginal(
|
||||||
WebPageId localId,
|
WebPageId localId,
|
||||||
|
|
|
@ -629,6 +629,11 @@ struct HistoryServiceGiveawayResults
|
||||||
, public HistoryServiceDependentData {
|
, public HistoryServiceDependentData {
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct HistoryServiceCustomLink
|
||||||
|
: public RuntimeComponent<HistoryServiceCustomLink, HistoryItem> {
|
||||||
|
ClickHandlerPtr link;
|
||||||
|
};
|
||||||
|
|
||||||
enum class HistorySelfDestructType {
|
enum class HistorySelfDestructType {
|
||||||
Photo,
|
Photo,
|
||||||
Video,
|
Video,
|
||||||
|
|
|
@ -11,6 +11,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "api/api_sending.h"
|
#include "api/api_sending.h"
|
||||||
#include "apiwrap.h"
|
#include "apiwrap.h"
|
||||||
#include "base/random.h"
|
#include "base/random.h"
|
||||||
|
#include "boxes/premium_preview_box.h"
|
||||||
#include "chat_helpers/stickers_lottie.h"
|
#include "chat_helpers/stickers_lottie.h"
|
||||||
#include "core/click_handler_types.h"
|
#include "core/click_handler_types.h"
|
||||||
#include "data/business/data_business_common.h"
|
#include "data/business/data_business_common.h"
|
||||||
|
@ -28,6 +29,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "history/history_item_reply_markup.h"
|
#include "history/history_item_reply_markup.h"
|
||||||
#include "lang/lang_keys.h"
|
#include "lang/lang_keys.h"
|
||||||
#include "main/main_session.h"
|
#include "main/main_session.h"
|
||||||
|
#include "settings/business/settings_chat_intro.h"
|
||||||
#include "settings/settings_premium.h"
|
#include "settings/settings_premium.h"
|
||||||
#include "ui/chat/chat_style.h"
|
#include "ui/chat/chat_style.h"
|
||||||
#include "ui/text/text_utilities.h"
|
#include "ui/text/text_utilities.h"
|
||||||
|
@ -237,7 +239,7 @@ bool AboutView::refresh() {
|
||||||
const auto user = _history->peer->asUser();
|
const auto user = _history->peer->asUser();
|
||||||
const auto info = user ? user->botInfo.get() : nullptr;
|
const auto info = user ? user->botInfo.get() : nullptr;
|
||||||
if (!info) {
|
if (!info) {
|
||||||
if (user && _history->isDisplayedEmpty()) {
|
if (user && !user->isSelf() && _history->isDisplayedEmpty()) {
|
||||||
if (_item) {
|
if (_item) {
|
||||||
return false;
|
return false;
|
||||||
} else if (user->meRequiresPremiumToWrite()
|
} else if (user->meRequiresPremiumToWrite()
|
||||||
|
@ -269,13 +271,16 @@ void AboutView::makeIntro(not_null<UserData*> user) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void AboutView::make(Data::ChatIntro data) {
|
void AboutView::make(Data::ChatIntro data) {
|
||||||
|
const auto text = data
|
||||||
|
? tr::lng_action_set_chat_intro(tr::now, lt_from, _history->peer->name())
|
||||||
|
: QString();
|
||||||
const auto item = _history->makeMessage({
|
const auto item = _history->makeMessage({
|
||||||
.id = _history->nextNonHistoryEntryId(),
|
.id = _history->nextNonHistoryEntryId(),
|
||||||
.flags = (MessageFlag::FakeAboutView
|
.flags = (MessageFlag::FakeAboutView
|
||||||
| MessageFlag::FakeHistoryItem
|
| MessageFlag::FakeHistoryItem
|
||||||
| MessageFlag::Local),
|
| MessageFlag::Local),
|
||||||
.from = _history->peer->id,
|
.from = _history->peer->id,
|
||||||
}, PreparedServiceText{ { } });
|
}, PreparedServiceText{ { text }});
|
||||||
|
|
||||||
if (data.sticker) {
|
if (data.sticker) {
|
||||||
_helloChosen = nullptr;
|
_helloChosen = nullptr;
|
||||||
|
@ -287,13 +292,26 @@ void AboutView::make(Data::ChatIntro data) {
|
||||||
const auto helloChosen = [=](not_null<DocumentData*> sticker) {
|
const auto helloChosen = [=](not_null<DocumentData*> sticker) {
|
||||||
setHelloChosen(sticker);
|
setHelloChosen(sticker);
|
||||||
};
|
};
|
||||||
|
const auto handler = [=](ClickContext context) {
|
||||||
|
const auto my = context.other.value<ClickHandlerContext>();
|
||||||
|
if (const auto controller = my.sessionWindow.get()) {
|
||||||
|
if (controller->session().premium()) {
|
||||||
|
controller->showSettings(Settings::ChatIntroId());
|
||||||
|
} else {
|
||||||
|
ShowPremiumPreviewBox(
|
||||||
|
controller->uiShow(),
|
||||||
|
PremiumFeature::ChatIntro);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
owned->overrideMedia(std::make_unique<HistoryView::MediaGeneric>(
|
owned->overrideMedia(std::make_unique<HistoryView::MediaGeneric>(
|
||||||
owned.get(),
|
owned.get(),
|
||||||
GenerateChatIntro(owned.get(), _item.get(), data, helloChosen),
|
GenerateChatIntro(owned.get(), _item.get(), data, helloChosen),
|
||||||
HistoryView::MediaGenericDescriptor{
|
HistoryView::MediaGenericDescriptor{
|
||||||
.maxWidth = st::chatIntroWidth,
|
.maxWidth = st::chatIntroWidth,
|
||||||
|
.serviceLink = std::make_shared<LambdaClickHandler>(handler),
|
||||||
.service = true,
|
.service = true,
|
||||||
.hideServiceText = true,
|
.hideServiceText = text.isEmpty(),
|
||||||
}));
|
}));
|
||||||
if (!data.sticker && _helloChosen) {
|
if (!data.sticker && _helloChosen) {
|
||||||
data.sticker = _helloChosen;
|
data.sticker = _helloChosen;
|
||||||
|
|
|
@ -677,6 +677,8 @@ TextState Service::textState(QPoint point, StateRequest request) const {
|
||||||
result.link = same->lnk;
|
result.link = same->lnk;
|
||||||
} else if (const auto results = item->Get<HistoryServiceGiveawayResults>()) {
|
} else if (const auto results = item->Get<HistoryServiceGiveawayResults>()) {
|
||||||
result.link = results->lnk;
|
result.link = results->lnk;
|
||||||
|
} else if (const auto custom = item->Get<HistoryServiceCustomLink>()) {
|
||||||
|
result.link = custom->link;
|
||||||
} else if (media && data()->showSimilarChannels()) {
|
} else if (media && data()->showSimilarChannels()) {
|
||||||
result = media->textState(mediaPoint, request);
|
result = media->textState(mediaPoint, request);
|
||||||
}
|
}
|
||||||
|
|
|
@ -80,6 +80,10 @@ MediaGeneric::MediaGeneric(
|
||||||
.object = std::move(part),
|
.object = std::move(part),
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
if (descriptor.serviceLink) {
|
||||||
|
parent->data()->setCustomServiceLink(
|
||||||
|
std::move(descriptor.serviceLink));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MediaGeneric::~MediaGeneric() {
|
MediaGeneric::~MediaGeneric() {
|
||||||
|
|
|
@ -45,6 +45,7 @@ public:
|
||||||
|
|
||||||
struct MediaGenericDescriptor {
|
struct MediaGenericDescriptor {
|
||||||
int maxWidth = 0;
|
int maxWidth = 0;
|
||||||
|
ClickHandlerPtr serviceLink;
|
||||||
bool service = false;
|
bool service = false;
|
||||||
bool hideServiceText = false;
|
bool hideServiceText = false;
|
||||||
};
|
};
|
||||||
|
|
|
@ -684,7 +684,7 @@ std::vector<PremiumFeature> BusinessFeaturesOrder(
|
||||||
return PremiumFeature::BusinessLocation;
|
return PremiumFeature::BusinessLocation;
|
||||||
} else if (s == u"business_bots"_q) {
|
} else if (s == u"business_bots"_q) {
|
||||||
return PremiumFeature::BusinessBots;
|
return PremiumFeature::BusinessBots;
|
||||||
} else if (s == u"chat_intro"_q) {
|
} else if (s == u"business_intro"_q) {
|
||||||
return PremiumFeature::ChatIntro;
|
return PremiumFeature::ChatIntro;
|
||||||
}
|
}
|
||||||
return PremiumFeature::kCount;
|
return PremiumFeature::kCount;
|
||||||
|
|
Loading…
Add table
Reference in a new issue