mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-16 06:07:06 +02:00
feat: local premium
This commit is contained in:
parent
16ccab05d4
commit
ae16aa3099
8 changed files with 85 additions and 1 deletions
|
@ -4057,4 +4057,5 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
"ayu_IDCopiedToast" = "ID copied to clipboard.";
|
||||
"ayu_ContextHideMessage" = "Hide";
|
||||
"ayu_ContextCopyCallbackData" = "Copy Callback Data";
|
||||
"ayu_LocalPremiumNotice" = "You're using **local** Telegram Premium.\nIt **won't** give you any benefits, except translator.\n**Enjoy the star near your nickname!**";
|
||||
"ayu_SettingsWatermark" = "AyuGram developed and maintained by Radolyn Labs.";
|
||||
|
|
|
@ -219,6 +219,11 @@ namespace AyuSettings
|
|||
disableStories = val;
|
||||
}
|
||||
|
||||
void AyuGramSettings::set_localPremium(bool val)
|
||||
{
|
||||
localPremium = val;
|
||||
}
|
||||
|
||||
void AyuGramSettings::set_deletedMark(QString val)
|
||||
{
|
||||
deletedMark = std::move(val);
|
||||
|
|
|
@ -36,6 +36,7 @@ namespace AyuSettings
|
|||
// ~ QoL toggles
|
||||
disableAds = true;
|
||||
disableStories = false;
|
||||
localPremium = false;
|
||||
copyUsernameAsLink = true;
|
||||
|
||||
// ~ Customization
|
||||
|
@ -71,6 +72,7 @@ namespace AyuSettings
|
|||
bool saveMessagesHistory;
|
||||
bool disableAds;
|
||||
bool disableStories;
|
||||
bool localPremium;
|
||||
bool copyUsernameAsLink;
|
||||
QString deletedMark;
|
||||
QString editedMark;
|
||||
|
@ -108,6 +110,8 @@ namespace AyuSettings
|
|||
|
||||
void set_disableStories(bool val);
|
||||
|
||||
void set_localPremium(bool val);
|
||||
|
||||
void set_copyUsernameAsLink(bool val);
|
||||
|
||||
void set_deletedMark(QString val);
|
||||
|
@ -144,6 +148,7 @@ namespace AyuSettings
|
|||
saveMessagesHistory,
|
||||
disableAds,
|
||||
disableStories,
|
||||
localPremium,
|
||||
copyUsernameAsLink,
|
||||
deletedMark,
|
||||
editedMark,
|
||||
|
@ -173,4 +178,4 @@ namespace AyuSettings
|
|||
bool get_ghostModeEnabled();
|
||||
|
||||
rpl::producer<bool> get_ghostModeEnabledReactive();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -503,6 +503,22 @@ namespace Settings
|
|||
AyuSettings::save();
|
||||
}, container->lifetime());
|
||||
|
||||
AddButton(
|
||||
container,
|
||||
tr::ayu_LocalPremium(),
|
||||
st::settingsButtonNoIcon
|
||||
)->toggleOn(
|
||||
rpl::single(settings->localPremium)
|
||||
)->toggledValue(
|
||||
) | rpl::filter([=](bool enabled)
|
||||
{
|
||||
return (enabled != settings->localPremium);
|
||||
}) | start_with_next([=](bool enabled)
|
||||
{
|
||||
settings->set_localPremium(enabled);
|
||||
AyuSettings::save();
|
||||
}, container->lifetime());
|
||||
|
||||
AddButton(
|
||||
container,
|
||||
tr::ayu_DisableStories(),
|
||||
|
|
|
@ -21,6 +21,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "ui/image/image_prepare.h"
|
||||
#include "base/unixtime.h"
|
||||
|
||||
// AyuGram includes
|
||||
#include "ayu/ayu_settings.h"
|
||||
|
||||
|
||||
namespace Data {
|
||||
namespace {
|
||||
|
||||
|
@ -377,6 +381,11 @@ rpl::producer<bool> PeerPremiumValue(not_null<PeerData*> peer) {
|
|||
}
|
||||
|
||||
rpl::producer<bool> AmPremiumValue(not_null<Main::Session*> session) {
|
||||
auto settings = &AyuSettings::getInstance();
|
||||
if (settings->localPremium) {
|
||||
return rpl::single(true);
|
||||
}
|
||||
|
||||
return PeerPremiumValue(session->user());
|
||||
}
|
||||
|
||||
|
|
|
@ -26,6 +26,11 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "lang/lang_keys.h"
|
||||
#include "styles/style_chat.h"
|
||||
|
||||
// AyuGram includes
|
||||
#include "ayu/ayu_settings.h"
|
||||
#include "ayu/sync/utils/telegram_helpers.h"
|
||||
|
||||
|
||||
namespace {
|
||||
|
||||
// User with hidden last seen stays online in UI for such amount of seconds.
|
||||
|
@ -341,6 +346,18 @@ bool UserData::isFake() const {
|
|||
}
|
||||
|
||||
bool UserData::isPremium() const {
|
||||
if (id) {
|
||||
auto settings = &AyuSettings::getInstance();
|
||||
if (settings->localPremium)
|
||||
{
|
||||
if (getSession(id.value))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return flags() & UserDataFlag::Premium;
|
||||
}
|
||||
|
||||
|
|
|
@ -50,6 +50,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "chat_helpers/spellchecker_common.h"
|
||||
#endif // TDESKTOP_DISABLE_SPELLCHECK
|
||||
|
||||
// AyuGram includes
|
||||
#include "ayu/ayu_settings.h"
|
||||
|
||||
|
||||
namespace Main {
|
||||
namespace {
|
||||
|
||||
|
@ -237,10 +241,20 @@ rpl::producer<> Session::downloaderTaskFinished() const {
|
|||
}
|
||||
|
||||
bool Session::premium() const {
|
||||
auto settings = &AyuSettings::getInstance();
|
||||
if (settings->localPremium) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return _user->isPremium();
|
||||
}
|
||||
|
||||
bool Session::premiumPossible() const {
|
||||
auto settings = &AyuSettings::getInstance();
|
||||
if (settings->localPremium) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return premium() || _premiumPossible.current();
|
||||
}
|
||||
|
||||
|
@ -257,6 +271,12 @@ rpl::producer<bool> Session::premiumPossibleValue() const {
|
|||
}) | rpl::map([=] {
|
||||
return _user->isPremium();
|
||||
});
|
||||
|
||||
auto settings = &AyuSettings::getInstance();
|
||||
if (settings->localPremium) {
|
||||
premium = rpl::single(true);
|
||||
}
|
||||
|
||||
return rpl::combine(
|
||||
std::move(premium),
|
||||
_premiumPossible.value(),
|
||||
|
|
|
@ -62,6 +62,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "styles/style_layers.h"
|
||||
#include "styles/style_settings.h"
|
||||
|
||||
// AyuGram includes
|
||||
#include "ayu/ayu_settings.h"
|
||||
|
||||
|
||||
namespace Settings {
|
||||
namespace {
|
||||
|
||||
|
@ -1478,6 +1482,13 @@ QPointer<Ui::RpWidget> Premium::createPinnedToTop(
|
|||
Ui::Text::RichLangValue);
|
||||
}
|
||||
}
|
||||
|
||||
auto settings = &AyuSettings::getInstance();
|
||||
if (settings->localPremium)
|
||||
{
|
||||
return tr::ayu_LocalPremiumNotice(Ui::Text::RichLangValue);
|
||||
}
|
||||
|
||||
return rpl::conditional(
|
||||
Data::AmPremiumValue(&_controller->session()),
|
||||
_controller->session().api().premium().statusTextValue(),
|
||||
|
|
Loading…
Add table
Reference in a new issue