mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +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_IDCopiedToast" = "ID copied to clipboard.";
|
||||||
"ayu_ContextHideMessage" = "Hide";
|
"ayu_ContextHideMessage" = "Hide";
|
||||||
"ayu_ContextCopyCallbackData" = "Copy Callback Data";
|
"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.";
|
"ayu_SettingsWatermark" = "AyuGram developed and maintained by Radolyn Labs.";
|
||||||
|
|
|
@ -219,6 +219,11 @@ namespace AyuSettings
|
||||||
disableStories = val;
|
disableStories = val;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AyuGramSettings::set_localPremium(bool val)
|
||||||
|
{
|
||||||
|
localPremium = val;
|
||||||
|
}
|
||||||
|
|
||||||
void AyuGramSettings::set_deletedMark(QString val)
|
void AyuGramSettings::set_deletedMark(QString val)
|
||||||
{
|
{
|
||||||
deletedMark = std::move(val);
|
deletedMark = std::move(val);
|
||||||
|
|
|
@ -36,6 +36,7 @@ namespace AyuSettings
|
||||||
// ~ QoL toggles
|
// ~ QoL toggles
|
||||||
disableAds = true;
|
disableAds = true;
|
||||||
disableStories = false;
|
disableStories = false;
|
||||||
|
localPremium = false;
|
||||||
copyUsernameAsLink = true;
|
copyUsernameAsLink = true;
|
||||||
|
|
||||||
// ~ Customization
|
// ~ Customization
|
||||||
|
@ -71,6 +72,7 @@ namespace AyuSettings
|
||||||
bool saveMessagesHistory;
|
bool saveMessagesHistory;
|
||||||
bool disableAds;
|
bool disableAds;
|
||||||
bool disableStories;
|
bool disableStories;
|
||||||
|
bool localPremium;
|
||||||
bool copyUsernameAsLink;
|
bool copyUsernameAsLink;
|
||||||
QString deletedMark;
|
QString deletedMark;
|
||||||
QString editedMark;
|
QString editedMark;
|
||||||
|
@ -108,6 +110,8 @@ namespace AyuSettings
|
||||||
|
|
||||||
void set_disableStories(bool val);
|
void set_disableStories(bool val);
|
||||||
|
|
||||||
|
void set_localPremium(bool val);
|
||||||
|
|
||||||
void set_copyUsernameAsLink(bool val);
|
void set_copyUsernameAsLink(bool val);
|
||||||
|
|
||||||
void set_deletedMark(QString val);
|
void set_deletedMark(QString val);
|
||||||
|
@ -144,6 +148,7 @@ namespace AyuSettings
|
||||||
saveMessagesHistory,
|
saveMessagesHistory,
|
||||||
disableAds,
|
disableAds,
|
||||||
disableStories,
|
disableStories,
|
||||||
|
localPremium,
|
||||||
copyUsernameAsLink,
|
copyUsernameAsLink,
|
||||||
deletedMark,
|
deletedMark,
|
||||||
editedMark,
|
editedMark,
|
||||||
|
@ -173,4 +178,4 @@ namespace AyuSettings
|
||||||
bool get_ghostModeEnabled();
|
bool get_ghostModeEnabled();
|
||||||
|
|
||||||
rpl::producer<bool> get_ghostModeEnabledReactive();
|
rpl::producer<bool> get_ghostModeEnabledReactive();
|
||||||
}
|
}
|
||||||
|
|
|
@ -503,6 +503,22 @@ namespace Settings
|
||||||
AyuSettings::save();
|
AyuSettings::save();
|
||||||
}, container->lifetime());
|
}, 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(
|
AddButton(
|
||||||
container,
|
container,
|
||||||
tr::ayu_DisableStories(),
|
tr::ayu_DisableStories(),
|
||||||
|
|
|
@ -21,6 +21,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "ui/image/image_prepare.h"
|
#include "ui/image/image_prepare.h"
|
||||||
#include "base/unixtime.h"
|
#include "base/unixtime.h"
|
||||||
|
|
||||||
|
// AyuGram includes
|
||||||
|
#include "ayu/ayu_settings.h"
|
||||||
|
|
||||||
|
|
||||||
namespace Data {
|
namespace Data {
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
|
@ -377,6 +381,11 @@ rpl::producer<bool> PeerPremiumValue(not_null<PeerData*> peer) {
|
||||||
}
|
}
|
||||||
|
|
||||||
rpl::producer<bool> AmPremiumValue(not_null<Main::Session*> session) {
|
rpl::producer<bool> AmPremiumValue(not_null<Main::Session*> session) {
|
||||||
|
auto settings = &AyuSettings::getInstance();
|
||||||
|
if (settings->localPremium) {
|
||||||
|
return rpl::single(true);
|
||||||
|
}
|
||||||
|
|
||||||
return PeerPremiumValue(session->user());
|
return PeerPremiumValue(session->user());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,6 +26,11 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "lang/lang_keys.h"
|
#include "lang/lang_keys.h"
|
||||||
#include "styles/style_chat.h"
|
#include "styles/style_chat.h"
|
||||||
|
|
||||||
|
// AyuGram includes
|
||||||
|
#include "ayu/ayu_settings.h"
|
||||||
|
#include "ayu/sync/utils/telegram_helpers.h"
|
||||||
|
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
// User with hidden last seen stays online in UI for such amount of seconds.
|
// 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 {
|
bool UserData::isPremium() const {
|
||||||
|
if (id) {
|
||||||
|
auto settings = &AyuSettings::getInstance();
|
||||||
|
if (settings->localPremium)
|
||||||
|
{
|
||||||
|
if (getSession(id.value))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
return flags() & UserDataFlag::Premium;
|
return flags() & UserDataFlag::Premium;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -50,6 +50,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "chat_helpers/spellchecker_common.h"
|
#include "chat_helpers/spellchecker_common.h"
|
||||||
#endif // TDESKTOP_DISABLE_SPELLCHECK
|
#endif // TDESKTOP_DISABLE_SPELLCHECK
|
||||||
|
|
||||||
|
// AyuGram includes
|
||||||
|
#include "ayu/ayu_settings.h"
|
||||||
|
|
||||||
|
|
||||||
namespace Main {
|
namespace Main {
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
|
@ -237,10 +241,20 @@ rpl::producer<> Session::downloaderTaskFinished() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Session::premium() const {
|
bool Session::premium() const {
|
||||||
|
auto settings = &AyuSettings::getInstance();
|
||||||
|
if (settings->localPremium) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
return _user->isPremium();
|
return _user->isPremium();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Session::premiumPossible() const {
|
bool Session::premiumPossible() const {
|
||||||
|
auto settings = &AyuSettings::getInstance();
|
||||||
|
if (settings->localPremium) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
return premium() || _premiumPossible.current();
|
return premium() || _premiumPossible.current();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -257,6 +271,12 @@ rpl::producer<bool> Session::premiumPossibleValue() const {
|
||||||
}) | rpl::map([=] {
|
}) | rpl::map([=] {
|
||||||
return _user->isPremium();
|
return _user->isPremium();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
auto settings = &AyuSettings::getInstance();
|
||||||
|
if (settings->localPremium) {
|
||||||
|
premium = rpl::single(true);
|
||||||
|
}
|
||||||
|
|
||||||
return rpl::combine(
|
return rpl::combine(
|
||||||
std::move(premium),
|
std::move(premium),
|
||||||
_premiumPossible.value(),
|
_premiumPossible.value(),
|
||||||
|
|
|
@ -62,6 +62,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "styles/style_layers.h"
|
#include "styles/style_layers.h"
|
||||||
#include "styles/style_settings.h"
|
#include "styles/style_settings.h"
|
||||||
|
|
||||||
|
// AyuGram includes
|
||||||
|
#include "ayu/ayu_settings.h"
|
||||||
|
|
||||||
|
|
||||||
namespace Settings {
|
namespace Settings {
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
|
@ -1478,6 +1482,13 @@ QPointer<Ui::RpWidget> Premium::createPinnedToTop(
|
||||||
Ui::Text::RichLangValue);
|
Ui::Text::RichLangValue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto settings = &AyuSettings::getInstance();
|
||||||
|
if (settings->localPremium)
|
||||||
|
{
|
||||||
|
return tr::ayu_LocalPremiumNotice(Ui::Text::RichLangValue);
|
||||||
|
}
|
||||||
|
|
||||||
return rpl::conditional(
|
return rpl::conditional(
|
||||||
Data::AmPremiumValue(&_controller->session()),
|
Data::AmPremiumValue(&_controller->session()),
|
||||||
_controller->session().api().premium().statusTextValue(),
|
_controller->session().api().premium().statusTextValue(),
|
||||||
|
|
Loading…
Add table
Reference in a new issue