TF-3985 Allow retry get paywall url when paywall is not available
This commit is contained in:
+3
@@ -309,6 +309,7 @@ class MailboxDashBoardController extends ReloadableController
|
||||
int minInputLengthAutocomplete = AppConfig.defaultMinInputLengthAutocomplete;
|
||||
EmailSortOrderType currentSortOrder = SearchEmailFilter.defaultSortOrder;
|
||||
PaywallUrlPattern? paywallUrlPattern;
|
||||
bool isRetryGetPaywallUrl = false;
|
||||
|
||||
final StreamController<Either<Failure, Success>> _progressStateController =
|
||||
StreamController<Either<Failure, Success>>.broadcast();
|
||||
@@ -551,6 +552,8 @@ class MailboxDashBoardController extends ReloadableController
|
||||
tryGetAuthenticatedAccountToUseApp();
|
||||
} else if (isGetTokenOIDCFailure(failure)) {
|
||||
backToHomeScreen();
|
||||
} else if (failure is GetPaywallUrlFailure) {
|
||||
loadPaywallUrlFailure();
|
||||
} else {
|
||||
super.handleFailureViewState(failure);
|
||||
}
|
||||
|
||||
+49
-5
@@ -1,4 +1,6 @@
|
||||
import 'package:core/presentation/extensions/color_extension.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_svg/flutter_svg.dart';
|
||||
import 'package:tmail_ui_user/features/mailbox_dashboard/presentation/controller/mailbox_dashboard_controller.dart';
|
||||
import 'package:tmail_ui_user/features/paywall/domain/model/paywall_url_pattern.dart';
|
||||
import 'package:tmail_ui_user/features/paywall/domain/usecases/get_paywall_url_interactor.dart';
|
||||
@@ -7,7 +9,7 @@ import 'package:tmail_ui_user/main/routes/route_navigation.dart';
|
||||
import 'package:tmail_ui_user/main/routes/route_utils.dart';
|
||||
import 'package:tmail_ui_user/main/utils/app_utils.dart';
|
||||
|
||||
extension ValidateSaasPremiumAvailableExtension on MailboxDashBoardController {
|
||||
extension HandlePaywallExtension on MailboxDashBoardController {
|
||||
bool validatePremiumIsAvailable() {
|
||||
if (accountId.value == null || sessionCurrent == null) {
|
||||
return false;
|
||||
@@ -26,6 +28,10 @@ extension ValidateSaasPremiumAvailableExtension on MailboxDashBoardController {
|
||||
consumeState(getPaywallUrlInteractor.execute(jmapUrl));
|
||||
} else {
|
||||
paywallUrlPattern = null;
|
||||
if (isRetryGetPaywallUrl) {
|
||||
_showMessagePaywallUrlNotAvailable();
|
||||
isRetryGetPaywallUrl = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,12 +39,45 @@ extension ValidateSaasPremiumAvailableExtension on MailboxDashBoardController {
|
||||
paywallUrlPattern = newPattern;
|
||||
}
|
||||
|
||||
void loadPaywallUrlFailure() {
|
||||
paywallUrlPattern = null;
|
||||
if (isRetryGetPaywallUrl) {
|
||||
_showMessagePaywallUrlNotAvailable();
|
||||
isRetryGetPaywallUrl = false;
|
||||
}
|
||||
}
|
||||
|
||||
void _showMessagePaywallUrlNotAvailable({BuildContext? context}) {
|
||||
final overlayContext = context ?? currentOverlayContext;
|
||||
AppLocalizations? appLocalizations;
|
||||
if (context != null) {
|
||||
appLocalizations = AppLocalizations.of(context);
|
||||
} else if (currentContext != null) {
|
||||
appLocalizations = AppLocalizations.of(currentContext!);
|
||||
}
|
||||
|
||||
if (overlayContext == null || appLocalizations == null) return;
|
||||
|
||||
appToast.showToastMessage(
|
||||
overlayContext,
|
||||
appLocalizations.paywallUrlNotAvailable,
|
||||
actionName: appLocalizations.retry,
|
||||
onActionClick: _handleRetryGetPaywallUrl,
|
||||
leadingSVGIcon: imagePaths.icQuotasWarning,
|
||||
leadingSVGIconColor: Colors.white,
|
||||
backgroundColor: AppColor.toastErrorBackgroundColor,
|
||||
textColor: Colors.white,
|
||||
actionIcon: SvgPicture.asset(
|
||||
imagePaths.icRefreshQuotas,
|
||||
colorFilter: Colors.white.asFilter(),
|
||||
),
|
||||
duration: const Duration(seconds: 5),
|
||||
);
|
||||
}
|
||||
|
||||
void navigateToPaywall(BuildContext context) {
|
||||
if (paywallUrlPattern == null) {
|
||||
appToast.showToastErrorMessage(
|
||||
context,
|
||||
AppLocalizations.of(context).paywallUrlNotAvailable,
|
||||
);
|
||||
_showMessagePaywallUrlNotAvailable(context: context);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -49,4 +88,9 @@ extension ValidateSaasPremiumAvailableExtension on MailboxDashBoardController {
|
||||
|
||||
AppUtils.launchLink(qualifiedPaywall);
|
||||
}
|
||||
|
||||
void _handleRetryGetPaywallUrl() {
|
||||
isRetryGetPaywallUrl = true;
|
||||
loadPaywallUrl();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user