You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
55 lines
1.7 KiB
Dart
55 lines
1.7 KiB
Dart
import 'package:fluffychat/pangea/constants/url_query_parameter_keys.dart';
|
|
import 'package:fluffychat/pangea/controllers/pangea_controller.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:go_router/go_router.dart';
|
|
import 'package:sentry_flutter/sentry_flutter.dart';
|
|
|
|
import '../../../widgets/matrix.dart';
|
|
import '../../constants/local.key.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
|
|
class JoinClassWithLink extends StatefulWidget {
|
|
const JoinClassWithLink({super.key});
|
|
|
|
@override
|
|
State<JoinClassWithLink> createState() => _JoinClassWithLinkState();
|
|
}
|
|
|
|
//PTODO - show class info in field so they know they're joining the right class
|
|
class _JoinClassWithLinkState extends State<JoinClassWithLink> {
|
|
String? classCode;
|
|
final PangeaController _pangeaController = MatrixState.pangeaController;
|
|
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
|
|
Future.delayed(Duration.zero, () async {
|
|
classCode = GoRouterState.of(context)
|
|
.uri
|
|
.queryParameters[UrlQueryParameterKeys.classCode];
|
|
|
|
if (classCode == null) {
|
|
Sentry.addBreadcrumb(
|
|
Breadcrumb(
|
|
message:
|
|
"Navigated to join_with_link without class code query parameter",
|
|
),
|
|
);
|
|
return;
|
|
}
|
|
|
|
await _pangeaController.pStoreService.save(
|
|
PLocalKey.cachedClassCodeToJoin,
|
|
classCode,
|
|
isAccountData: false,
|
|
);
|
|
context.go("/home");
|
|
});
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) => const SizedBox();
|
|
}
|