mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Allow hiding Premium Stickers fake-sticker-set.
This commit is contained in:
parent
4bdac53be2
commit
068d3caef5
3 changed files with 52 additions and 15 deletions
|
@ -1424,6 +1424,8 @@ bool StickersListWidget::hasRemoveButton(int index) const {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return !set.stickers.empty() && _megagroupSet->canEditStickers();
|
return !set.stickers.empty() && _megagroupSet->canEditStickers();
|
||||||
|
} else if (set.id == Data::Stickers::PremiumSetId) {
|
||||||
|
return !set.stickers.empty();
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -1666,10 +1668,6 @@ void StickersListWidget::mouseReleaseEvent(QMouseEvent *e) {
|
||||||
Assert(button->section >= 0 && button->section < sets.size());
|
Assert(button->section >= 0 && button->section < sets.size());
|
||||||
if (sets[button->section].externalLayout) {
|
if (sets[button->section].externalLayout) {
|
||||||
_localSetsManager->install(sets[button->section].id);
|
_localSetsManager->install(sets[button->section].id);
|
||||||
} else if (sets[button->section].id == Data::Stickers::MegagroupSetId) {
|
|
||||||
auto removeLocally = sets[button->section].stickers.empty()
|
|
||||||
|| !_megagroupSet->canEditStickers();
|
|
||||||
removeMegagroupSet(removeLocally);
|
|
||||||
} else {
|
} else {
|
||||||
removeSet(sets[button->section].id);
|
removeSet(sets[button->section].id);
|
||||||
}
|
}
|
||||||
|
@ -2134,7 +2132,8 @@ void StickersListWidget::refreshRecentStickers(bool performResize) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void StickersListWidget::refreshPremiumStickers() {
|
void StickersListWidget::refreshPremiumStickers() {
|
||||||
if (_isMasks) {
|
if (_isMasks
|
||||||
|
|| controller()->session().settings().skipPremiumStickersSet()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
clearSelection();
|
clearSelection();
|
||||||
|
@ -2617,7 +2616,14 @@ void StickersListWidget::removeMegagroupSet(bool locally) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void StickersListWidget::removeSet(uint64 setId) {
|
void StickersListWidget::removeSet(uint64 setId) {
|
||||||
if (auto box = MakeConfirmRemoveSetBox(&session(), setId)) {
|
if (setId == Data::Stickers::MegagroupSetId) {
|
||||||
|
const auto &sets = shownSets();
|
||||||
|
const auto i = ranges::find(sets, setId, &Set::id);
|
||||||
|
Assert(i != end(sets));
|
||||||
|
const auto removeLocally = i->stickers.empty()
|
||||||
|
|| !_megagroupSet->canEditStickers();
|
||||||
|
removeMegagroupSet(removeLocally);
|
||||||
|
} else if (auto box = MakeConfirmRemoveSetBox(&session(), setId)) {
|
||||||
checkHideWithBox(controller()->show(
|
checkHideWithBox(controller()->show(
|
||||||
std::move(box),
|
std::move(box),
|
||||||
Ui::LayerOption::KeepOther));
|
Ui::LayerOption::KeepOther));
|
||||||
|
@ -2645,6 +2651,22 @@ StickersListWidget::~StickersListWidget() = default;
|
||||||
object_ptr<Ui::BoxContent> MakeConfirmRemoveSetBox(
|
object_ptr<Ui::BoxContent> MakeConfirmRemoveSetBox(
|
||||||
not_null<Main::Session*> session,
|
not_null<Main::Session*> session,
|
||||||
uint64 setId) {
|
uint64 setId) {
|
||||||
|
if (setId == Data::Stickers::PremiumSetId) {
|
||||||
|
return Ui::MakeConfirmBox({
|
||||||
|
.text = tr::lng_stickers_remove_pack(
|
||||||
|
tr::now,
|
||||||
|
lt_sticker_pack,
|
||||||
|
tr::lng_premium_stickers(tr::now)),
|
||||||
|
.confirmed = [=](Fn<void()> &&close) {
|
||||||
|
close();
|
||||||
|
session->settings().setSkipPremiumStickersSet(true);
|
||||||
|
session->saveSettingsDelayed();
|
||||||
|
session->data().stickers().notifyUpdated(
|
||||||
|
Data::StickersType::Stickers);
|
||||||
|
},
|
||||||
|
.confirmText = tr::lng_stickers_remove_pack_confirm(),
|
||||||
|
});
|
||||||
|
}
|
||||||
const auto &sets = session->data().stickers().sets();
|
const auto &sets = session->data().stickers().sets();
|
||||||
const auto it = sets.find(setId);
|
const auto it = sets.find(setId);
|
||||||
if (it == sets.cend()) {
|
if (it == sets.cend()) {
|
||||||
|
@ -2716,9 +2738,6 @@ object_ptr<Ui::BoxContent> MakeConfirmRemoveSetBox(
|
||||||
session->data().stickers().notifyUpdated(set->type());
|
session->data().stickers().notifyUpdated(set->type());
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
.cancelled = [=](Fn<void()> &&close) {
|
|
||||||
close();
|
|
||||||
},
|
|
||||||
.confirmText = tr::lng_stickers_remove_pack_confirm(),
|
.confirmText = tr::lng_stickers_remove_pack_confirm(),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,13 +34,17 @@ SessionSettings::SessionSettings()
|
||||||
|
|
||||||
QByteArray SessionSettings::serialize() const {
|
QByteArray SessionSettings::serialize() const {
|
||||||
const auto autoDownload = _autoDownload.serialize();
|
const auto autoDownload = _autoDownload.serialize();
|
||||||
auto size = sizeof(qint32) * 38;
|
auto size = sizeof(qint32) * 4
|
||||||
size += _groupStickersSectionHidden.size() * sizeof(quint64);
|
+ _groupStickersSectionHidden.size() * sizeof(quint64)
|
||||||
size += _mediaLastPlaybackPosition.size() * 2 * sizeof(quint64);
|
+ sizeof(qint32) * 4
|
||||||
size += Serialize::bytearraySize(autoDownload);
|
+ Serialize::bytearraySize(autoDownload)
|
||||||
size += sizeof(qint32)
|
+ sizeof(qint32) * 5
|
||||||
|
+ _mediaLastPlaybackPosition.size() * 2 * sizeof(quint64)
|
||||||
|
+ sizeof(qint32) * 5
|
||||||
+ _hiddenPinnedMessages.size() * (sizeof(quint64) + sizeof(qint32))
|
+ _hiddenPinnedMessages.size() * (sizeof(quint64) + sizeof(qint32))
|
||||||
+ (_mutePeriods.size() * sizeof(quint64));
|
+ sizeof(qint32)
|
||||||
|
+ (_mutePeriods.size() * sizeof(quint64))
|
||||||
|
+ sizeof(qint32);
|
||||||
|
|
||||||
auto result = QByteArray();
|
auto result = QByteArray();
|
||||||
result.reserve(size);
|
result.reserve(size);
|
||||||
|
@ -78,6 +82,7 @@ QByteArray SessionSettings::serialize() const {
|
||||||
for (const auto &period : _mutePeriods) {
|
for (const auto &period : _mutePeriods) {
|
||||||
stream << quint64(period);
|
stream << quint64(period);
|
||||||
}
|
}
|
||||||
|
stream << qint32(_skipPremiumStickersSet ? 1 : 0);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -139,6 +144,7 @@ void SessionSettings::addFromSerialized(const QByteArray &serialized) {
|
||||||
qint32 supportAllSilent = _supportAllSilent ? 1 : 0;
|
qint32 supportAllSilent = _supportAllSilent ? 1 : 0;
|
||||||
qint32 photoEditorHintShowsCount = _photoEditorHintShowsCount;
|
qint32 photoEditorHintShowsCount = _photoEditorHintShowsCount;
|
||||||
std::vector<TimeId> mutePeriods;
|
std::vector<TimeId> mutePeriods;
|
||||||
|
qint32 skipPremiumStickersSet = _skipPremiumStickersSet ? 1 : 0;
|
||||||
|
|
||||||
stream >> versionTag;
|
stream >> versionTag;
|
||||||
if (versionTag == kVersionTag) {
|
if (versionTag == kVersionTag) {
|
||||||
|
@ -369,6 +375,9 @@ void SessionSettings::addFromSerialized(const QByteArray &serialized) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (!stream.atEnd()) {
|
||||||
|
stream >> skipPremiumStickersSet;
|
||||||
|
}
|
||||||
if (stream.status() != QDataStream::Ok) {
|
if (stream.status() != QDataStream::Ok) {
|
||||||
LOG(("App Error: "
|
LOG(("App Error: "
|
||||||
"Bad data for SessionSettings::addFromSerialized()"));
|
"Bad data for SessionSettings::addFromSerialized()"));
|
||||||
|
@ -413,6 +422,7 @@ void SessionSettings::addFromSerialized(const QByteArray &serialized) {
|
||||||
_supportAllSilent = (supportAllSilent == 1);
|
_supportAllSilent = (supportAllSilent == 1);
|
||||||
_photoEditorHintShowsCount = std::move(photoEditorHintShowsCount);
|
_photoEditorHintShowsCount = std::move(photoEditorHintShowsCount);
|
||||||
_mutePeriods = std::move(mutePeriods);
|
_mutePeriods = std::move(mutePeriods);
|
||||||
|
_skipPremiumStickersSet = (skipPremiumStickersSet == 1);
|
||||||
|
|
||||||
if (version < 2) {
|
if (version < 2) {
|
||||||
app.setLastSeenWarningSeen(appLastSeenWarningSeen == 1);
|
app.setLastSeenWarningSeen(appLastSeenWarningSeen == 1);
|
||||||
|
|
|
@ -126,6 +126,13 @@ public:
|
||||||
[[nodiscard]] std::vector<TimeId> mutePeriods() const;
|
[[nodiscard]] std::vector<TimeId> mutePeriods() const;
|
||||||
void addMutePeriod(TimeId period);
|
void addMutePeriod(TimeId period);
|
||||||
|
|
||||||
|
[[nodiscard]] bool skipPremiumStickersSet() const {
|
||||||
|
return _skipPremiumStickersSet;
|
||||||
|
}
|
||||||
|
void setSkipPremiumStickersSet(bool value) {
|
||||||
|
_skipPremiumStickersSet = value;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static constexpr auto kDefaultSupportChatsLimitSlice = 7 * 24 * 60 * 60;
|
static constexpr auto kDefaultSupportChatsLimitSlice = 7 * 24 * 60 * 60;
|
||||||
static constexpr auto kPhotoEditorHintMaxShowsCount = 5;
|
static constexpr auto kPhotoEditorHintMaxShowsCount = 5;
|
||||||
|
@ -142,6 +149,7 @@ private:
|
||||||
bool _dialogsFiltersEnabled = false;
|
bool _dialogsFiltersEnabled = false;
|
||||||
int _photoEditorHintShowsCount = 0;
|
int _photoEditorHintShowsCount = 0;
|
||||||
std::vector<TimeId> _mutePeriods;
|
std::vector<TimeId> _mutePeriods;
|
||||||
|
bool _skipPremiumStickersSet = false;
|
||||||
|
|
||||||
Support::SwitchSettings _supportSwitch;
|
Support::SwitchSettings _supportSwitch;
|
||||||
bool _supportFixChatsOrder = true;
|
bool _supportFixChatsOrder = true;
|
||||||
|
|
Loading…
Add table
Reference in a new issue