mirror of
https://github.com/amnezia-vpn/amnezia-client.git
synced 2026-05-08 14:33:23 +00:00
fix: hide renew button for appstore purchases
This commit is contained in:
@@ -757,6 +757,9 @@ bool ApiConfigsController::updateServiceFromGateway(const int serverIndex, const
|
||||
newApiConfig.insert(configKey::serviceType, apiConfig.value(configKey::serviceType));
|
||||
newApiConfig.insert(configKey::serviceProtocol, apiConfig.value(configKey::serviceProtocol));
|
||||
newApiConfig.insert(apiDefs::key::vpnKey, apiConfig.value(apiDefs::key::vpnKey));
|
||||
if (apiConfig.contains(apiDefs::key::isInAppPurchase)) {
|
||||
newApiConfig.insert(apiDefs::key::isInAppPurchase, apiConfig.value(apiDefs::key::isInAppPurchase));
|
||||
}
|
||||
|
||||
newServerConfig.insert(configKey::apiConfig, newApiConfig);
|
||||
newServerConfig.insert(configKey::authData, gatewayRequestData.authData);
|
||||
@@ -782,7 +785,11 @@ bool ApiConfigsController::updateServiceFromGateway(const int serverIndex, const
|
||||
return true;
|
||||
} else {
|
||||
if (errorCode == ErrorCode::ApiSubscriptionExpiredError) {
|
||||
emit subscriptionExpiredOnServer();
|
||||
if (!apiConfig.value(apiDefs::key::isInAppPurchase).toBool(false)) {
|
||||
emit subscriptionExpiredOnServer();
|
||||
} else {
|
||||
emit errorOccurred(errorCode);
|
||||
}
|
||||
} else {
|
||||
emit errorOccurred(errorCode);
|
||||
}
|
||||
|
||||
@@ -80,6 +80,9 @@ QVariant ApiAccountInfoModel::data(const QModelIndex &index, int role) const
|
||||
if (m_accountInfoData.configType == apiDefs::ConfigType::AmneziaFreeV3) {
|
||||
return false;
|
||||
}
|
||||
if (m_accountInfoData.isInAppPurchase) {
|
||||
return false;
|
||||
}
|
||||
if (m_accountInfoData.subscriptionEndDate.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
@@ -89,11 +92,17 @@ QVariant ApiAccountInfoModel::data(const QModelIndex &index, int role) const
|
||||
if (m_accountInfoData.configType == apiDefs::ConfigType::AmneziaFreeV3) {
|
||||
return false;
|
||||
}
|
||||
if (m_accountInfoData.isInAppPurchase) {
|
||||
return false;
|
||||
}
|
||||
if (m_accountInfoData.subscriptionEndDate.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
return apiUtils::isSubscriptionExpiringSoon(m_accountInfoData.subscriptionEndDate);
|
||||
}
|
||||
case IsInAppPurchaseRole: {
|
||||
return m_accountInfoData.isInAppPurchase;
|
||||
}
|
||||
}
|
||||
|
||||
return QVariant();
|
||||
@@ -114,6 +123,9 @@ void ApiAccountInfoModel::updateModel(const QJsonObject &accountInfoObject, cons
|
||||
|
||||
accountInfoData.configType = apiUtils::getConfigType(serverConfig);
|
||||
|
||||
const QJsonObject apiConfig = serverConfig.value(apiDefs::key::apiConfig).toObject();
|
||||
accountInfoData.isInAppPurchase = apiConfig.value(apiDefs::key::isInAppPurchase).toBool(false);
|
||||
|
||||
accountInfoData.subscriptionDescription = accountInfoObject.value(apiDefs::key::subscriptionDescription).toString();
|
||||
|
||||
for (const auto &protocol : accountInfoObject.value(apiDefs::key::supportedProtocols).toArray()) {
|
||||
@@ -187,6 +199,7 @@ QHash<int, QByteArray> ApiAccountInfoModel::roleNames() const
|
||||
roles[IsProtocolSelectionSupportedRole] = "isProtocolSelectionSupported";
|
||||
roles[IsSubscriptionExpiredRole] = "isSubscriptionExpired";
|
||||
roles[IsSubscriptionExpiringSoonRole] = "isSubscriptionExpiringSoon";
|
||||
roles[IsInAppPurchaseRole] = "isInAppPurchase";
|
||||
|
||||
return roles;
|
||||
}
|
||||
|
||||
@@ -21,7 +21,8 @@ public:
|
||||
HasExpiredWorkerRole,
|
||||
IsProtocolSelectionSupportedRole,
|
||||
IsSubscriptionExpiredRole,
|
||||
IsSubscriptionExpiringSoonRole
|
||||
IsSubscriptionExpiringSoonRole,
|
||||
IsInAppPurchaseRole
|
||||
};
|
||||
|
||||
explicit ApiAccountInfoModel(QObject *parent = nullptr);
|
||||
@@ -57,6 +58,8 @@ private:
|
||||
QStringList supportedProtocols;
|
||||
|
||||
QString subscriptionDescription;
|
||||
|
||||
bool isInAppPurchase = false;
|
||||
};
|
||||
|
||||
AccountInfoData m_accountInfoData;
|
||||
|
||||
@@ -183,6 +183,9 @@ QVariant ServersModel::data(const QModelIndex &index, int role) const
|
||||
if (configVersion != apiDefs::ConfigSource::AmneziaGateway) {
|
||||
return false;
|
||||
}
|
||||
if (apiConfig.value(apiDefs::key::isInAppPurchase).toBool(false)) {
|
||||
return false;
|
||||
}
|
||||
const QString endDate =
|
||||
apiConfig.value(apiDefs::key::subscription).toObject().value(apiDefs::key::endDate).toString();
|
||||
if (endDate.isEmpty()) {
|
||||
@@ -194,6 +197,9 @@ QVariant ServersModel::data(const QModelIndex &index, int role) const
|
||||
if (configVersion != apiDefs::ConfigSource::AmneziaGateway) {
|
||||
return false;
|
||||
}
|
||||
if (apiConfig.value(apiDefs::key::isInAppPurchase).toBool(false)) {
|
||||
return false;
|
||||
}
|
||||
const QString endDate =
|
||||
apiConfig.value(apiDefs::key::subscription).toObject().value(apiDefs::key::endDate).toString();
|
||||
if (endDate.isEmpty()) {
|
||||
|
||||
@@ -55,11 +55,13 @@ PageType {
|
||||
property bool isSubscriptionExpired: false
|
||||
property bool isSubscriptionExpiringSoon: false
|
||||
property bool isSubscriptionRenewalAvailable: false
|
||||
property bool isInAppPurchase: false
|
||||
|
||||
function updateSubscriptionState() {
|
||||
root.isSubscriptionExpired = ApiAccountInfoModel.data("isSubscriptionExpired")
|
||||
root.isSubscriptionExpiringSoon = ApiAccountInfoModel.data("isSubscriptionExpiringSoon")
|
||||
root.isSubscriptionRenewalAvailable = ApiAccountInfoModel.data("isComponentVisible")
|
||||
root.isInAppPurchase = ApiAccountInfoModel.data("isInAppPurchase")
|
||||
}
|
||||
|
||||
Component.onCompleted: {
|
||||
@@ -168,7 +170,7 @@ PageType {
|
||||
|
||||
BasicButtonType {
|
||||
visible: (root.isSubscriptionExpired || root.isSubscriptionExpiringSoon)
|
||||
&& root.isSubscriptionRenewalAvailable
|
||||
&& root.isSubscriptionRenewalAvailable && !root.isInAppPurchase
|
||||
|
||||
Layout.fillWidth: true
|
||||
Layout.leftMargin: 16
|
||||
@@ -226,7 +228,7 @@ PageType {
|
||||
|
||||
BasicButtonType {
|
||||
visible: !root.isSubscriptionExpired && !root.isSubscriptionExpiringSoon
|
||||
&& root.isSubscriptionRenewalAvailable
|
||||
&& root.isSubscriptionRenewalAvailable && !root.isInAppPurchase
|
||||
|
||||
Layout.alignment: Qt.AlignHCenter
|
||||
Layout.topMargin: 16
|
||||
@@ -250,7 +252,7 @@ PageType {
|
||||
|
||||
DividerType {
|
||||
visible: !root.isSubscriptionExpired && !root.isSubscriptionExpiringSoon
|
||||
&& root.isSubscriptionRenewalAvailable
|
||||
&& root.isSubscriptionRenewalAvailable && !root.isInAppPurchase
|
||||
}
|
||||
|
||||
SwitcherType {
|
||||
|
||||
Reference in New Issue
Block a user