Skip to content

Commit

Permalink
move local keys to local keys file, use local storage to show web sub…
Browse files Browse the repository at this point in the history
…scription success snackbar
  • Loading branch information
ggurdin committed Dec 11, 2023
1 parent 3f44ced commit 9c6b12d
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 4 deletions.
10 changes: 10 additions & 0 deletions lib/pages/chat_list/chat_list.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import 'package:fluffychat/config/app_config.dart';
import 'package:fluffychat/config/themes.dart';
import 'package:fluffychat/pages/chat_list/chat_list_view.dart';
import 'package:fluffychat/pages/settings_security/settings_security.dart';
import 'package:fluffychat/pangea/constants/local.key.dart';
import 'package:fluffychat/pangea/controllers/pangea_controller.dart';
import 'package:fluffychat/pangea/extensions/pangea_room_extension.dart';
import 'package:fluffychat/pangea/utils/add_to_space.dart';
Expand Down Expand Up @@ -757,6 +758,15 @@ class ChatListController extends State<ChatList>
await pangeaController.subscriptionController.initialize();
pangeaController.afterSyncAndFirstLoginInitialization(context);
await pangeaController.inviteBotToExistingSpaces();
final bool? beganWebPayment = pangeaController.pStoreService.read(
PLocalKey.beganWebPayment,
);
if (beganWebPayment ?? false) {
pangeaController.pStoreService.delete(PLocalKey.beganWebPayment);
if (pangeaController.subscriptionController.isSubscribed) {
showSubscribedSnackbar(context);
}
}
} else {
ErrorHandler.logError(
m: "didn't run afterSyncAndFirstLoginInitialization because not mounted",
Expand Down
4 changes: 4 additions & 0 deletions lib/pangea/constants/local.key.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,8 @@ class PLocalKey {
static const String classes = 'classes';

static const String cachedClassCodeToJoin = "cachedclasscodetojoin";
static const String beganWebPayment = "beganWebPayment";

// making this a random string so that it's harder to guess
static const String activatedTrialKey = '7C4EuKIsph';
}
12 changes: 8 additions & 4 deletions lib/pangea/controllers/subscription_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import 'dart:convert';

import 'package:adaptive_dialog/adaptive_dialog.dart';
import 'package:fluffychat/config/app_config.dart';
import 'package:fluffychat/pangea/constants/local.key.dart';
import 'package:fluffychat/pangea/controllers/base_controller.dart';
import 'package:fluffychat/pangea/controllers/pangea_controller.dart';
import 'package:fluffychat/pangea/models/base_subscription_info.dart';
Expand Down Expand Up @@ -82,14 +83,13 @@ class SubscriptionController extends BaseController {
}
}

final String activatedTrialKey = 'activatedTrial';

bool get activatedNewUserTrial =>
_pangeaController.userController.inTrialWindow &&
(_pangeaController.pStoreService.read(activatedTrialKey) ?? false);
(_pangeaController.pStoreService.read(PLocalKey.activatedTrialKey) ??
false);

void activateNewUserTrial() {
_pangeaController.pStoreService.save(activatedTrialKey, true);
_pangeaController.pStoreService.save(PLocalKey.activatedTrialKey, true);
setNewUserTrial();
}

Expand Down Expand Up @@ -204,6 +204,10 @@ class SubscriptionController extends BaseController {
selectedSubscription.duration!,
isPromo: isPromo,
);
_pangeaController.pStoreService.save(
PLocalKey.beganWebPayment,
true,
);
setState();
launchUrlString(
paymentLink,
Expand Down

0 comments on commit 9c6b12d

Please sign in to comment.