feat: add option to show only added emojis & stickers

This commit is contained in:
Grigory 2025-04-25 02:54:29 +05:00 committed by GitHub
parent 8f29e32577
commit 314a90995a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 45 additions and 1 deletions

View file

@ -6623,3 +6623,4 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
"ayu_AboutText1" = "ToS breaking Telegram client based on {api_link}.";
"ayu_UpdateAyuGram" = "Update AyuGram";
"ayu_UtilityRestartRequired" = "App will close in 5 seconds.";
"ayu_ShowOnlyAddedEmojisAndStickers" = "Show Only Added Emojis and Stickers";

View file

@ -380,6 +380,10 @@ void AyuGramSettings::set_disableCustomBackgrounds(bool val) {
disableCustomBackgrounds = val;
}
void AyuGramSettings::set_showOnlyAddedEmojisAndStickers(bool val) {
showOnlyAddedEmojisAndStickers = val;
}
void AyuGramSettings::set_collapseSimilarChannels(bool val) {
collapseSimilarChannels = val;
}

View file

@ -37,6 +37,7 @@ public:
bool disableAds;
bool disableStories;
bool disableCustomBackgrounds;
bool showOnlyAddedEmojisAndStickers;
bool collapseSimilarChannels;
bool hideSimilarChannels;
@ -117,6 +118,7 @@ public:
void set_disableAds(bool val);
void set_disableStories(bool val);
void set_disableCustomBackgrounds(bool val);
void set_showOnlyAddedEmojisAndStickers(bool val);
void set_collapseSimilarChannels(bool val);
void set_hideSimilarChannels(bool val);

View file

@ -767,6 +767,25 @@ void SetupQoLToggles(not_null<Ui::VerticalLayout*> container) {
},
container->lifetime());
AddButtonWithIcon(
container,
tr::ayu_ShowOnlyAddedEmojisAndStickers(),
st::settingsButtonNoIcon
)->toggleOn(
rpl::single(settings->showOnlyAddedEmojisAndStickers)
)->toggledValue(
) | rpl::filter(
[=](bool enabled)
{
return (enabled != settings->showOnlyAddedEmojisAndStickers);
}) | start_with_next(
[=](bool enabled)
{
settings->set_showOnlyAddedEmojisAndStickers(enabled);
AyuSettings::save();
},
container->lifetime());
std::vector checkboxes = {
NestedEntry{
tr::ayu_CollapseSimilarChannels(tr::now), settings->collapseSimilarChannels, [=](bool enabled)

View file

@ -55,6 +55,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include <QtWidgets/QApplication>
// AyuGram includes
#include "ayu/ayu_settings.h"
namespace ChatHelpers {
namespace {
@ -2255,9 +2258,13 @@ void EmojiListWidget::refreshCustom() {
&& !_allowWithoutPremium;
const auto owner = &session->data();
const auto &sets = owner->stickers().sets();
auto settings = &AyuSettings::getInstance();
const auto push = [&](uint64 setId, bool installed) {
const auto megagroup = _megagroupSet
&& (setId == Data::Stickers::MegagroupSetId);
if (settings->showOnlyAddedEmojisAndStickers && !installed && !megagroup) {
return;
}
const auto lookupId = megagroup
? _megagroupSet->mgInfo->emojiSet.id
: setId;

View file

@ -54,6 +54,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include <QtWidgets/QApplication>
// AyuGram includes
#include "ayu/ayu_settings.h"
namespace ChatHelpers {
namespace {
@ -404,9 +407,13 @@ bool FieldAutocomplete::clearFilteredBotCommands() {
FieldAutocomplete::StickerRows FieldAutocomplete::getStickerSuggestions() {
const auto data = &_session->data().stickers();
const auto list = data->getListByEmoji({ _emoji }, _stickersSeed);
const auto settings = &AyuSettings::getInstance();
auto result = ranges::views::all(
list
) | ranges::views::transform([](not_null<DocumentData*> sticker) {
) | ranges::views::filter([&](not_null<DocumentData*> sticker) {
return !settings->showOnlyAddedEmojisAndStickers
|| sticker->isStickerSetInstalled();
}) | ranges::views::transform([](not_null<DocumentData*> sticker) {
return StickerSuggestion{
sticker,
sticker->createMediaView()

View file

@ -763,6 +763,10 @@ void StickersListWidget::fillFilteredStickersRow() {
}
void StickersListWidget::addSearchRow(not_null<StickersSet*> set) {
const auto settings = &AyuSettings::getInstance();
if (settings->showOnlyAddedEmojisAndStickers && !SetInMyList(set->flags)) {
return;
}
const auto skipPremium = !session().premiumPossible();
auto elements = PrepareStickers(
set->stickers.empty() ? set->covers : set->stickers,