mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2026-07-25 06:54:43 +00:00
Removed premium section on first rate-limited summary click.
Fixed #30201.
This commit is contained in:
@@ -116,19 +116,14 @@ void Transcribes::toggle(not_null<HistoryItem*> item) {
|
||||
}
|
||||
}
|
||||
|
||||
void Transcribes::toggleSummary(
|
||||
not_null<HistoryItem*> item,
|
||||
Fn<void()> onPremiumRequired) {
|
||||
void Transcribes::toggleSummary(not_null<HistoryItem*> item) {
|
||||
const auto id = item->fullId();
|
||||
auto i = _summaries.find(id);
|
||||
if (i == _summaries.end()) {
|
||||
auto &entry = _summaries.emplace(id).first->second;
|
||||
entry.onPremiumRequired = std::move(onPremiumRequired);
|
||||
summarize(item);
|
||||
} else if (!i->second.loading) {
|
||||
auto &entry = i->second;
|
||||
if (entry.result.empty()) {
|
||||
entry.onPremiumRequired = std::move(onPremiumRequired);
|
||||
summarize(item);
|
||||
} else {
|
||||
entry.shown = entry.premiumRequired ? false : !entry.shown;
|
||||
@@ -265,7 +260,6 @@ void Transcribes::summarize(not_null<HistoryItem*> item) {
|
||||
entry.requestId = 0;
|
||||
entry.loading = false;
|
||||
entry.premiumRequired = false;
|
||||
entry.onPremiumRequired = nullptr;
|
||||
entry.languageId = translatedTo;
|
||||
entry.result = TextWithEntities(
|
||||
qs(data.vtext()),
|
||||
@@ -277,15 +271,11 @@ void Transcribes::summarize(not_null<HistoryItem*> item) {
|
||||
}).fail([=](const MTP::Error &error) {
|
||||
auto &entry = _summaries[id];
|
||||
if (error.type() == u"SUMMARY_FLOOD_PREMIUM"_q) {
|
||||
if (!entry.premiumRequired && entry.onPremiumRequired) {
|
||||
entry.onPremiumRequired();
|
||||
}
|
||||
entry.premiumRequired = true;
|
||||
}
|
||||
entry.requestId = 0;
|
||||
entry.shown = false;
|
||||
entry.loading = false;
|
||||
entry.onPremiumRequired = nullptr;
|
||||
if (const auto item = _session->data().message(id)) {
|
||||
_session->data().requestItemTextRefresh(item);
|
||||
}
|
||||
|
||||
@@ -19,7 +19,6 @@ class Session;
|
||||
namespace Api {
|
||||
|
||||
struct SummaryEntry {
|
||||
Fn<void()> onPremiumRequired = nullptr;
|
||||
TextWithEntities result;
|
||||
LanguageId languageId;
|
||||
bool shown = false;
|
||||
@@ -45,9 +44,7 @@ public:
|
||||
void toggle(not_null<HistoryItem*> item);
|
||||
[[nodiscard]] const Entry &entry(not_null<HistoryItem*> item) const;
|
||||
|
||||
void toggleSummary(
|
||||
not_null<HistoryItem*> item,
|
||||
Fn<void()> onPremiumRequired);
|
||||
void toggleSummary(not_null<HistoryItem*> item);
|
||||
[[nodiscard]] const SummaryEntry &summary(
|
||||
not_null<const HistoryItem*> item) const;
|
||||
void checkSummaryToTranslate(FullMsgId id);
|
||||
|
||||
@@ -73,7 +73,7 @@ void SummaryHeader::update(not_null<Element*> view) {
|
||||
}
|
||||
}
|
||||
if (const auto item = session->data().message(itemId)) {
|
||||
session->api().transcribes().toggleSummary(item, nullptr);
|
||||
session->api().transcribes().toggleSummary(item);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -381,7 +381,7 @@ ClickHandlerPtr TranscribeButton::link() {
|
||||
if (session->premium()) {
|
||||
auto &transcribes = session->api().transcribes();
|
||||
return summarize
|
||||
? transcribes.toggleSummary(item, nullptr)
|
||||
? transcribes.toggleSummary(item)
|
||||
: transcribes.toggle(item);
|
||||
}
|
||||
const auto my = context.other.value<ClickHandlerContext>();
|
||||
@@ -410,15 +410,7 @@ ClickHandlerPtr TranscribeButton::link() {
|
||||
}
|
||||
}
|
||||
if (summarize) {
|
||||
const auto weak = my.sessionWindow;
|
||||
session->api().transcribes().toggleSummary(item, [=] {
|
||||
if (const auto strong = weak.get()) {
|
||||
Settings::ShowPremium(strong, u"summary"_q);
|
||||
// ShowPremiumPreviewBox(
|
||||
// strong,
|
||||
// PremiumFeature::VoiceToText);
|
||||
}
|
||||
});
|
||||
session->api().transcribes().toggleSummary(item);
|
||||
} else {
|
||||
session->api().transcribes().toggle(item);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user