From b3e266d564aec0395b833b4de7ba26f27d864fe3 Mon Sep 17 00:00:00 2001 From: LittleSheep Date: Tue, 7 May 2024 13:06:26 +0800 Subject: [PATCH] :bug: Bug fixes on realm missing post editor --- lib/router.dart | 8 ++++++++ lib/screens/explore.dart | 4 ++-- lib/screens/posts/moment_editor.dart | 4 +++- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/lib/router.dart b/lib/router.dart index 44e427b..21bf4a5 100644 --- a/lib/router.dart +++ b/lib/router.dart @@ -115,6 +115,14 @@ abstract class SolianRouter { name: 'realms.member', builder: (context, state) => RealmMemberScreen(realm: state.extra as Realm), ), + GoRoute( + path: '/realms/:realm/posts/publish/moments', + name: 'realms.posts.moments.editor', + builder: (context, state) => MomentEditorScreen( + editing: state.extra as Post?, + realm: state.pathParameters['realm'] + ), + ), GoRoute( path: '/realms/:realm/posts/:dataset/:alias', name: 'realms.posts.details', diff --git a/lib/screens/explore.dart b/lib/screens/explore.dart index 1f55582..30345d1 100644 --- a/lib/screens/explore.dart +++ b/lib/screens/explore.dart @@ -91,8 +91,8 @@ class _ExplorePostWidgetState extends State { child: const Icon(Icons.edit), onPressed: () async { final did = await SolianRouter.router.pushNamed( - 'posts.moments.editor', - queryParameters: {'realm': widget.realm}, + widget.realm == null ? 'posts.moments.editor' : 'realms.posts.moments.editor', + pathParameters: widget.realm == null ? {} : {'realm': widget.realm!}, ); if (did == true) _pagingController.refresh(); }, diff --git a/lib/screens/posts/moment_editor.dart b/lib/screens/posts/moment_editor.dart index fcd417f..f2049b6 100644 --- a/lib/screens/posts/moment_editor.dart +++ b/lib/screens/posts/moment_editor.dart @@ -16,8 +16,9 @@ import 'package:solian/widgets/posts/attachment_editor.dart'; class MomentEditorScreen extends StatefulWidget { final Post? editing; + final String? realm; - const MomentEditorScreen({super.key, this.editing}); + const MomentEditorScreen({super.key, this.editing, this.realm}); @override State createState() => _MomentEditorScreenState(); @@ -61,6 +62,7 @@ class _MomentEditorScreenState extends State { 'alias': _alias, 'content': _textController.value.text, 'attachments': _attachments, + 'realm': widget.realm, }); var res = await Response.fromStream(await auth.client!.send(req));