Skip to content

Commit

Permalink
8.0.4 Crash fixes (#1284)
Browse files Browse the repository at this point in the history
* Fix feature enable crash.

* Fix in app purchase array.
  • Loading branch information
jigar-f authored Jan 10, 2025
1 parent 2eae707 commit e1cb900
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 22 deletions.
7 changes: 5 additions & 2 deletions internalsdk/session_model.go
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ func (m *SessionModel) setupIosConfigure(configPath string, userId int, token st
}
m.iosConfigurer = global
log.Debug("Found global config IOS configure done")
m.checkAvailableFeatures()
return // Exit the loop after success
}
log.Debugf("global config not available, retrying...")
Expand Down Expand Up @@ -790,6 +791,9 @@ func (m *SessionModel) checkAvailableFeatures() {
// Check for ads feature
googleAdsEnabled := m.featureEnabled(config.FeatureInterstitialAds)
m.SetShowGoogleAds(googleAdsEnabled)
if googleAdsEnabled {
checkAdsEnabled(m)
}
}

// check if feature is enabled or not
Expand All @@ -809,9 +813,8 @@ func (m *SessionModel) featureEnabled(feature string) bool {
log.Errorf("Error while getting user id %v", err)
return false
}
log.Debugf("Feature country code %s", countryCode)
featureEnabled := m.iosConfigurer.FeatureEnabled(feature, common.Platform, common.DefaultAppName, common.ApplicationVersion, userId, isPro, countryCode)
log.Debugf("Feature enabled %s %v", feature, featureEnabled)
log.Debugf("Feature enabled %s %v with country %s", feature, featureEnabled, countryCode)
return featureEnabled
}

Expand Down
9 changes: 0 additions & 9 deletions ios/Runner/Lantern/Models/SessionModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -138,15 +138,6 @@ class SessionModel: BaseModel<InternalsdkSessionModel> {
logger.debug("Bandwidth message coming from tunnel")
updateBandwidth(bandwidth: bandwidthData)
}
case Constants.configupdate:
if let config = change![.newKey] as? Bool {
if config {
logger.debug("upcomming message from vpn config")
checkForAvaliabelFeature()
}

}

default:
logger.debug("Unknown message \(keyPath)")
}
Expand Down
4 changes: 3 additions & 1 deletion lib/core/service/app_purchase.dart
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ class AppPurchase {

String getPriceFromPlanId(String planId, {bool perMonthCost = false}) {
try {

final plan = _normalizePlan(planId);
for (var sku in plansSku) {
if (sku.id.toLowerCase() == plan.id.toLowerCase()) {
Expand All @@ -154,7 +155,8 @@ class AppPurchase {
}
}
} catch (e, stacktrace) {
Sentry.captureException(e, stackTrace: stacktrace);
Sentry.captureException(e,
stackTrace: stacktrace, hint: Hint.withMap({'planId': planId}));
mainLogger.e('Failed to get price from plan');
}
return "";
Expand Down
3 changes: 2 additions & 1 deletion lib/core/service/injection_container.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import 'package:lantern/core/service/app_purchase.dart';

final GetIt sl = GetIt.instance;

void init() {
void initServices() {
//Inject
sl.registerLazySingleton(() => AppPurchase());
sl<AppPurchase>().init();
}
13 changes: 6 additions & 7 deletions lib/features/checkout/plan_details.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import 'package:lantern/core/utils/common.dart';
import 'package:lantern/core/service/app_purchase.dart';
import 'package:lantern/core/utils/common.dart';
import 'package:lantern/core/utils/utils.dart';

class PlanCard extends StatefulWidget {
Expand All @@ -17,8 +17,6 @@ class PlanCard extends StatefulWidget {
}

class _PlanCardState extends State<PlanCard> {


@override
Widget build(BuildContext context) {
final planName = widget.plan.id.split('-')[0];
Expand Down Expand Up @@ -160,16 +158,17 @@ class _PlanCardState extends State<PlanCard> {
}
} else {
return CText(
'${widget.plan.totalCost} ${'billed_one_time'.i18n}',
'${widget.plan.totalCost} ${'billed_one_time'.i18n}',
style: tsBody2.copiedWith(color: grey5),
);
}
}



String getPrice(String totalCost, {bool perMonthCost = false}) {
final appPurchase = sl<AppPurchase>();
if (widget.plan.id == '') {
return totalCost;
}
final appStorePrice = appPurchase.getPriceFromPlanId(widget.plan.id,
perMonthCost: perMonthCost);
return appStorePrice == '' ? totalCost : appStorePrice;
Expand Down Expand Up @@ -201,6 +200,7 @@ class _PlanCardState extends State<PlanCard> {
_storeFlow();
break;
default:

///Support for legacy purchase flow
if (!sessionModel.isAuthEnabled.value!) {
_processLegacyCheckOut(context);
Expand Down Expand Up @@ -261,7 +261,6 @@ class _PlanCardState extends State<PlanCard> {
CheckoutLegacy(
plan: widget.plan,
isPro: widget.isPro,

),
);
}
Expand Down
3 changes: 1 addition & 2 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@ Future<void> main() async {
} else {
await _initGoogleMobileAds();
// Inject all the services
init();
sl<AppPurchase>().init();
initServices();
// Due to replica we are using lot of cache
// clear if goes to above limit
CustomCacheManager().clearCacheIfExceeded();
Expand Down

0 comments on commit e1cb900

Please sign in to comment.