refresh toolbar / input bar after activating free trial

This commit is contained in:
ggurdin 2024-05-08 14:53:41 -04:00
parent b0490034e3
commit c2f785795e
6 changed files with 33 additions and 42 deletions

View file

@ -50,11 +50,11 @@ class InputBar extends StatelessWidget {
List<Map<String, String?>> getSuggestions(String text) {
// #Pangea
final List<Map<String, String?>> ret = <Map<String, String?>>[];
// if (controller!.selection.baseOffset !=
// controller!.selection.extentOffset ||
// controller!.selection.baseOffset < 0) {
// return []; // no entries if there is selected text
// }
if (controller!.selection.baseOffset !=
controller!.selection.extentOffset ||
controller!.selection.baseOffset < 0) {
return []; // no entries if there is selected text
}
// Pangea#
final searchText =
controller!.text.substring(0, controller!.selection.baseOffset);

View file

@ -51,6 +51,7 @@ class Choreographer {
String? _lastChecked;
ChoreoMode choreoMode = ChoreoMode.igc;
final StreamController stateListener = StreamController();
StreamSubscription? trialStream;
Choreographer(this.pangeaController, this.chatController) {
_initialize();
@ -63,6 +64,9 @@ class Choreographer {
errorService = ErrorService(this);
altTranslator = AlternativeTranslator(this);
_textController.addListener(_onChangeListener);
trialStream = pangeaController
.subscriptionController.trialActivationStream.stream
.listen((_) => _onChangeListener);
clear();
}
@ -214,7 +218,7 @@ class Choreographer {
if (choreoMode == ChoreoMode.it &&
itController.isTranslationDone &&
!tokensOnly) {
debugger(when: kDebugMode);
// debugger(when: kDebugMode);
}
await (choreoMode == ChoreoMode.it && !itController.isTranslationDone
@ -413,6 +417,7 @@ class Choreographer {
dispose() {
_textController.dispose();
trialStream?.cancel();
}
LanguageModel? get l2Lang {

View file

@ -34,6 +34,7 @@ class SubscriptionController extends BaseController {
late PangeaController _pangeaController;
SubscriptionInfo? subscription;
final StreamController subscriptionStream = StreamController.broadcast();
final StreamController trialActivationStream = StreamController.broadcast();
SubscriptionController(PangeaController pangeaController) : super() {
_pangeaController = pangeaController;
@ -191,10 +192,13 @@ class SubscriptionController extends BaseController {
void activateNewUserTrial() {
_pangeaController.pStoreService
.save(
MatrixProfile.activatedFreeTrial.title,
true,
)
.then((_) => setNewUserTrial());
MatrixProfile.activatedFreeTrial.title,
true,
)
.then((_) {
setNewUserTrial();
trialActivationStream.add(true);
});
}
void setNewUserTrial() {

View file

@ -33,7 +33,6 @@ class MessageUnsubscribedCard extends StatelessWidget {
MatrixState.pangeaController.subscriptionController
.showPaywall(context);
}
MatrixState.pAnyState.closeOverlay();
}
return Padding(

View file

@ -1,13 +1,11 @@
import 'package:fluffychat/pangea/constants/url_query_parameter_keys.dart';
import 'package:fluffychat/pangea/controllers/pangea_controller.dart';
import 'package:fluffychat/pangea/utils/class_code.dart';
import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/l10n.dart';
import 'package:go_router/go_router.dart';
import 'package:sentry_flutter/sentry_flutter.dart';
import '../../../widgets/matrix.dart';
import '../../constants/local.key.dart';
import '../../utils/error_handler.dart';
//if on home with classcode in url and not logged in, then save it soemhow and after llogin, join class automatically
//if on home with classcode in url and logged in, then join class automatically
@ -33,37 +31,22 @@ class _JoinClassWithLinkState extends State<JoinClassWithLink> {
.queryParameters[UrlQueryParameterKeys.classCode];
if (classCode == null) {
return ClassCodeUtil.messageDialog(
context,
L10n.of(context)!.unableToFindClassCode,
() => context.go("/rooms"),
Sentry.addBreadcrumb(
Breadcrumb(
message:
"Navigated to join_with_link without class code query parameter",
),
);
}
if (!Matrix.of(context).client.isLogged()) {
await _pangeaController.pStoreService.save(
PLocalKey.cachedClassCodeToJoin,
classCode,
addClientIdToKey: false,
local: true,
);
context.go("/home");
return;
}
_pangeaController.classController
.joinClasswithCode(
context,
classCode!,
)
.onError((error, stackTrace) {
ClassCodeUtil.messageSnack(
context,
ErrorCopy(context, error).body,
);
}).whenComplete(
() => context.go("/rooms"),
await _pangeaController.pStoreService.save(
PLocalKey.cachedClassCodeToJoin,
classCode,
addClientIdToKey: false,
local: true,
);
context.go("/home");
});
}

View file

@ -77,9 +77,9 @@ class SpanCardState extends State<SpanCard> {
if (mounted) {
setState(() => fetchingData = false);
}
} catch (e) {
} catch (e, s) {
// debugger(when: kDebugMode);
ErrorHandler.logError(e: e, s: StackTrace.current);
ErrorHandler.logError(e: e, s: s);
if (mounted) {
setState(() {
error = e;