Skip to content

Commit

Permalink
Merge pull request #215 from pangeachat/new-group-query-instead-of-path
Browse files Browse the repository at this point in the history
New group uses query to store space ID
  • Loading branch information
ggurdin authored May 17, 2024
2 parents c0a56a3 + c88970d commit e156408
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 16 deletions.
30 changes: 18 additions & 12 deletions lib/config/routes.dart
Original file line number Diff line number Diff line change
Expand Up @@ -232,20 +232,26 @@ abstract class AppRoutes {
pageBuilder: (context, state) => defaultPageBuilder(
context,
state,
const NewGroup(),
NewGroup(
// #Pangea
spaceId: state.uri.queryParameters['spaceId'],
// Pangea#
),
),
redirect: loggedOutRedirect,
routes: [
GoRoute(
path: ':spaceid',
pageBuilder: (context, state) => defaultPageBuilder(
context,
state,
const NewGroup(),
),
redirect: loggedOutRedirect,
),
],
// #Pangea
// routes: [
// GoRoute(
// path: ':spaceid',
// pageBuilder: (context, state) => defaultPageBuilder(
// context,
// state,
// const NewGroup(),
// ),
// redirect: loggedOutRedirect,
// ),
// ],
// Pangea#
),
GoRoute(
path: 'newspace',
Expand Down
4 changes: 2 additions & 2 deletions lib/pages/chat_list/start_chat_fab.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class StartChatFloatingActionButton extends StatelessWidget {
void _onPressed(BuildContext context) async {
//#Pangea
if (controller.activeSpaceId != null) {
context.go('/rooms/newgroup/${controller.activeSpaceId ?? ''}');
context.go('/rooms/newgroup?spaceId=${controller.activeSpaceId ?? ''}');
return;
}
//Pangea#
Expand All @@ -44,7 +44,7 @@ class StartChatFloatingActionButton extends StatelessWidget {
case ActiveFilter.groups:
// #Pangea
// context.go('/rooms/newgroup');
context.go('/rooms/newgroup/${controller.activeSpaceId ?? ''}');
context.go('/rooms/newgroup?spaceId=${controller.activeSpaceId ?? ''}');
// Pangea#
break;
case ActiveFilter.spaces:
Expand Down
11 changes: 9 additions & 2 deletions lib/pages/new_group/new_group.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,14 @@ import 'package:go_router/go_router.dart';
import 'package:matrix/matrix.dart' as sdk;

class NewGroup extends StatefulWidget {
const NewGroup({super.key});
// #Pangea
final String? spaceId;

const NewGroup({
super.key,
this.spaceId,
});
// Pangea#

@override
NewGroupController createState() => NewGroupController();
Expand Down Expand Up @@ -50,7 +57,7 @@ class NewGroupController extends State<NewGroup> {
void setVocab(List<Lemma> vocab) => setState(() => chatTopic.vocab = vocab);

String? get activeSpaceId =>
GoRouterState.of(context).pathParameters['spaceid'];
GoRouterState.of(context).uri.queryParameters['spaceId'];
// Pangea#

void setPublicGroup(bool b) => setState(() => publicGroup = b);
Expand Down

0 comments on commit e156408

Please sign in to comment.