From 7dbbb2d6888ae04ddded639b0a1b5f3df1016e7f Mon Sep 17 00:00:00 2001 From: olorin99 Date: Mon, 23 Feb 2026 14:09:37 +1000 Subject: [PATCH 1/8] Add instance parameter to start of path. --- lib/src/app.dart | 10 ++++- lib/src/controller/router.dart | 76 ++++++++++++++++++---------------- lib/src/screens/app_home.dart | 17 ++++++++ 3 files changed, 67 insertions(+), 36 deletions(-) diff --git a/lib/src/app.dart b/lib/src/app.dart index 6188c714..c22efc53 100644 --- a/lib/src/app.dart +++ b/lib/src/app.dart @@ -1,3 +1,4 @@ +import 'package:auto_route/auto_route.dart'; import 'package:dynamic_color/dynamic_color.dart'; import 'package:flex_color_scheme/flex_color_scheme.dart'; import 'package:flutter/material.dart'; @@ -5,6 +6,7 @@ import 'package:flutter_localized_locales/flutter_localized_locales.dart'; import 'package:interstellar/l10n/app_localizations.dart'; import 'package:interstellar/src/controller/controller.dart'; import 'package:interstellar/src/controller/router.dart'; +import 'package:interstellar/src/controller/router.gr.dart'; import 'package:interstellar/src/screens/account/notification/notification_count_controller.dart'; import 'package:interstellar/src/utils/globals.dart'; import 'package:interstellar/src/utils/utils.dart'; @@ -45,7 +47,13 @@ class App extends StatelessWidget { textScaler: TextScaler.linear(ac.profile.globalTextScale), ), child: MaterialApp.router( - routerConfig: router.config(), + routerConfig: router.config( + deepLinkBuilder: (deepLink) { + return DeepLink([ + AppInstanceRoute(instance: ac.instanceHost), + ]); + }, + ), restorationScopeId: 'app', localizationsDelegates: const [ ...AppLocalizations.localizationsDelegates, diff --git a/lib/src/controller/router.dart b/lib/src/controller/router.dart index 19750786..b42f41ae 100644 --- a/lib/src/controller/router.dart +++ b/lib/src/controller/router.dart @@ -10,45 +10,51 @@ class AppRouter extends RootStackRouter { @override List get routes => [ - AutoRoute(page: AppHome.page, path: '/'), - AutoRoute(page: FeedRoute.page, path: '/feed'), - AutoRoute(page: ExploreRoute.page, path: '/explore'), + AutoRoute( + page: AppInstanceRoute.page, + path: '/:instance', + children: [ + AutoRoute(page: AppHome.page, path: ''), + AutoRoute(page: FeedRoute.page, path: 'feed'), + AutoRoute(page: ExploreRoute.page, path: 'explore'), - AutoRoute(page: ThreadRoute.page, path: '/thread/:id'), - AutoRoute(page: MicroblogRoute.page, path: '/microblog/:id'), - AutoRoute(page: PostCommentRoute.page, path: '/comment/:id'), - AutoRoute(page: ContentReplyRoute.page, path: '/reply'), + AutoRoute(page: ThreadRoute.page, path: 'thread/:id'), + AutoRoute(page: MicroblogRoute.page, path: 'microblog/:id'), + AutoRoute(page: PostCommentRoute.page, path: 'comment/:id'), + AutoRoute(page: ContentReplyRoute.page, path: 'reply'), - AutoRoute(page: UserRoute.page, path: '/user/:userId'), - AutoRoute(page: ModLogUserRoute.page, path: '/user/:userId/modlog'), - AutoRoute(page: MessageThreadRoute.page, path: '/user/:userId/message'), + AutoRoute(page: UserRoute.page, path: 'user/:userId'), + AutoRoute(page: ModLogUserRoute.page, path: 'user/:userId/modlog'), + AutoRoute(page: MessageThreadRoute.page, path: 'user/:userId/message'), - AutoRoute(page: CommunityRoute.page, path: '/community/:communityId'), - AutoRoute( - page: ModLogCommunityRoute.page, - path: '/community/:communityId/modlog', - ), - AutoRoute( - page: CommunityModPanelRoute.page, - path: '/community/:communityId/mod', - ), - AutoRoute( - page: CommunityOwnerPanelRoute.page, - path: '/community/:communityId/owner', - ), + AutoRoute(page: CommunityRoute.page, path: 'community/:communityId'), + AutoRoute( + page: ModLogCommunityRoute.page, + path: 'community/:communityId/modlog', + ), + AutoRoute( + page: CommunityModPanelRoute.page, + path: 'community/:communityId/mod', + ), + AutoRoute( + page: CommunityOwnerPanelRoute.page, + path: 'community/:communityId/owner', + ), - AutoRoute(page: ModLogRoute.page, path: '/modlog'), - AutoRoute(page: DomainRoute.page, path: '/domain'), - AutoRoute(page: CreateRoute.page, path: '/create'), - AutoRoute(page: AdvancedImageRoute.page, path: '/image'), - AutoRoute(page: TagUsersRoute.page, path: '/tags/:tag'), - AutoRoute(page: TagEditorRoute.page, path: '/tags-editor/:tag'), - AutoRoute(page: BookmarkListRoute.page, path: '/bookmarks'), - AutoRoute(page: BookmarksRoute.page, path: '/bookmarks/:bookmarkList'), - AutoRoute(page: ProfileEditRoute.page, path: '/account/edit'), - AutoRoute(page: EditProfileRoute.page, path: '/profile/edit'), - AutoRoute(page: EditFilterListRoute.page, path: '/filter/:filterList'), - AutoRoute(page: EditFeedRoute.page, path: '/feed/:feed/edit'), + AutoRoute(page: ModLogRoute.page, path: 'modlog'), + AutoRoute(page: DomainRoute.page, path: 'domain'), + AutoRoute(page: CreateRoute.page, path: 'create'), + AutoRoute(page: AdvancedImageRoute.page, path: 'image'), + AutoRoute(page: TagUsersRoute.page, path: 'tags/:tag'), + AutoRoute(page: TagEditorRoute.page, path: 'tags-editor/:tag'), + AutoRoute(page: BookmarkListRoute.page, path: 'bookmarks'), + AutoRoute(page: BookmarksRoute.page, path: 'bookmarks/:bookmarkList'), + AutoRoute(page: ProfileEditRoute.page, path: 'account/edit'), + AutoRoute(page: EditProfileRoute.page, path: 'profile/edit'), + AutoRoute(page: EditFilterListRoute.page, path: 'filter/:filterList'), + AutoRoute(page: EditFeedRoute.page, path: 'feed/:feed/edit'), + ], + ), //settings AutoRoute(page: BehaviorSettingsRoute.page, path: '/settings/behavior'), diff --git a/lib/src/screens/app_home.dart b/lib/src/screens/app_home.dart index 9494074b..75b10d70 100644 --- a/lib/src/screens/app_home.dart +++ b/lib/src/screens/app_home.dart @@ -4,6 +4,7 @@ import 'package:auto_route/auto_route.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:interstellar/src/controller/controller.dart'; +import 'package:interstellar/src/controller/router.dart'; import 'package:interstellar/src/controller/router.gr.dart'; import 'package:interstellar/src/screens/account/inbox_screen.dart'; import 'package:interstellar/src/screens/account/notification/notification_badge.dart'; @@ -20,6 +21,21 @@ import 'package:interstellar/src/widgets/wrapper.dart'; import 'package:material_symbols_icons/symbols.dart'; import 'package:provider/provider.dart'; +@RoutePage() +class AppInstanceScreen extends StatelessWidget { + const AppInstanceScreen({ + @PathParam('instance') required this.instance, + super.key, + }); + + final String instance; + + @override + Widget build(BuildContext context) { + return const Scaffold(body: AutoRouter()); + } +} + @RoutePage() class AppHome extends StatefulWidget { const AppHome({super.key}); @@ -123,6 +139,7 @@ class _AppHomeState extends State { _accountKey = UniqueKey(); _inboxKey = UniqueKey(); }); + context.router.root.replace(AppInstanceRoute(instance: ac.instanceHost)); }; final notCompact = !Breakpoints.isCompact(context); From 747c099169981a4283dcacae7fcb19826705a462 Mon Sep 17 00:00:00 2001 From: olorin99 Date: Mon, 23 Feb 2026 14:22:05 +1000 Subject: [PATCH 2/8] Switch user path to use username as identifier. --- lib/src/controller/router.dart | 9 ++++++--- .../account/messages/message_thread_item.dart | 5 ++++- .../notification/notification_item.dart | 5 ++++- lib/src/screens/account/self_feed.dart | 2 +- .../screens/explore/community_mod_panel.dart | 5 ++++- .../screens/explore/explore_screen_item.dart | 7 ++++++- lib/src/screens/explore/mod_log.dart | 16 ++++++++++++---- lib/src/screens/explore/user_item.dart | 4 +++- lib/src/screens/explore/user_screen.dart | 18 ++++++++++-------- lib/src/screens/feed/nav_drawer.dart | 7 ++++++- lib/src/widgets/content_item/content_info.dart | 5 +++-- lib/src/widgets/markdown/markdown_mention.dart | 5 +++-- lib/src/widgets/menus/user_menu.dart | 5 +++-- lib/src/widgets/tags/tag_screen.dart | 6 +++++- 14 files changed, 70 insertions(+), 29 deletions(-) diff --git a/lib/src/controller/router.dart b/lib/src/controller/router.dart index b42f41ae..39003fb0 100644 --- a/lib/src/controller/router.dart +++ b/lib/src/controller/router.dart @@ -23,9 +23,12 @@ class AppRouter extends RootStackRouter { AutoRoute(page: PostCommentRoute.page, path: 'comment/:id'), AutoRoute(page: ContentReplyRoute.page, path: 'reply'), - AutoRoute(page: UserRoute.page, path: 'user/:userId'), - AutoRoute(page: ModLogUserRoute.page, path: 'user/:userId/modlog'), - AutoRoute(page: MessageThreadRoute.page, path: 'user/:userId/message'), + AutoRoute(page: UserRoute.page, path: 'user/:username'), + AutoRoute(page: ModLogUserRoute.page, path: 'user/:username/modlog'), + AutoRoute( + page: MessageThreadRoute.page, + path: 'user/:username/message', + ), AutoRoute(page: CommunityRoute.page, path: 'community/:communityId'), AutoRoute( diff --git a/lib/src/screens/account/messages/message_thread_item.dart b/lib/src/screens/account/messages/message_thread_item.dart index abb70f91..f45a797c 100644 --- a/lib/src/screens/account/messages/message_thread_item.dart +++ b/lib/src/screens/account/messages/message_thread_item.dart @@ -100,7 +100,10 @@ class MessageThreadItem extends StatelessWidget { currMessage.sender.name, icon: currMessage.sender.avatar, onTap: () => context.router.push( - UserRoute(userId: currMessage.sender.id), + UserRoute( + username: currMessage.sender.name, + userId: currMessage.sender.id, + ), ), ), ], diff --git a/lib/src/screens/account/notification/notification_item.dart b/lib/src/screens/account/notification/notification_item.dart index 250ac637..e744262a 100644 --- a/lib/src/screens/account/notification/notification_item.dart +++ b/lib/src/screens/account/notification/notification_item.dart @@ -193,7 +193,10 @@ class _NotificationItemState extends State { widget.item.creator!.name, icon: widget.item.creator!.avatar, onTap: () => context.router.push( - UserRoute(userId: widget.item.creator!.id), + UserRoute( + username: widget.item.creator!.name, + userId: widget.item.creator!.id, + ), ), ), ), diff --git a/lib/src/screens/account/self_feed.dart b/lib/src/screens/account/self_feed.dart index b10507cd..393d187d 100644 --- a/lib/src/screens/account/self_feed.dart +++ b/lib/src/screens/account/self_feed.dart @@ -66,6 +66,6 @@ class _SelfFeedState extends State final user = _meUser!; - return UserScreen(user.id, initData: _meUser); + return UserScreen(username: user.name, userId: user.id, initData: _meUser); } } diff --git a/lib/src/screens/explore/community_mod_panel.dart b/lib/src/screens/explore/community_mod_panel.dart index c1fe392d..b0be340a 100644 --- a/lib/src/screens/explore/community_mod_panel.dart +++ b/lib/src/screens/explore/community_mod_panel.dart @@ -255,7 +255,10 @@ class _MagazineModPanelReportsState extends State { item.reportedBy!.name, icon: item.reportedBy!.avatar, onTap: () => context.router.push( - UserRoute(userId: item.reportedBy!.id), + UserRoute( + username: item.reportedBy!.name, + userId: item.reportedBy!.id, + ), ), ), ], diff --git a/lib/src/screens/explore/explore_screen_item.dart b/lib/src/screens/explore/explore_screen_item.dart index 29336a9d..b57f8be6 100644 --- a/lib/src/screens/explore/explore_screen_item.dart +++ b/lib/src/screens/explore/explore_screen_item.dart @@ -114,7 +114,12 @@ class ExploreScreenItem extends StatelessWidget { CommunityRoute(communityId: i.id, initData: i, onUpdate: onUpdate), ), final DetailedUserModel i => () => context.router.push( - UserRoute(userId: i.id, initData: i, onUpdate: onUpdate), + UserRoute( + username: i.name, + userId: i.id, + initData: i, + onUpdate: onUpdate, + ), ), final DomainModel i => () => context.router.push( DomainRoute(domainId: i.id, initData: i, onUpdate: onUpdate), diff --git a/lib/src/screens/explore/mod_log.dart b/lib/src/screens/explore/mod_log.dart index d3ab348d..4f5bce97 100644 --- a/lib/src/screens/explore/mod_log.dart +++ b/lib/src/screens/explore/mod_log.dart @@ -174,19 +174,27 @@ class _ModLogScreenState extends State { ModLogType.ban => item.user == null ? null - : () => context.router.push(UserRoute(userId: item.user!.id)), + : () => context.router.push( + UserRoute(username: item.user!.name, userId: item.user!.id), + ), ModLogType.unban => item.user == null ? null - : () => context.router.push(UserRoute(userId: item.user!.id)), + : () => context.router.push( + UserRoute(username: item.user!.name, userId: item.user!.id), + ), ModLogType.moderatorAdded => item.user == null ? null - : () => context.router.push(UserRoute(userId: item.user!.id)), + : () => context.router.push( + UserRoute(username: item.user!.name, userId: item.user!.id), + ), ModLogType.moderatorRemoved => item.user == null ? null - : () => context.router.push(UserRoute(userId: item.user!.id)), + : () => context.router.push( + UserRoute(username: item.user!.name, userId: item.user!.id), + ), ModLogType.communityAdded => () => context.router.push( CommunityRoute(communityId: item.community.id), ), diff --git a/lib/src/screens/explore/user_item.dart b/lib/src/screens/explore/user_item.dart index efc6c158..f054ee6b 100644 --- a/lib/src/screens/explore/user_item.dart +++ b/lib/src/screens/explore/user_item.dart @@ -24,7 +24,9 @@ class UserItemSimple extends StatelessWidget { return InkWell( onTap: noTap ? null - : () => context.router.push(UserRoute(userId: user.id)), + : () => context.router.push( + UserRoute(username: user.name, userId: user.id), + ), child: Padding( padding: const EdgeInsets.all(12), child: Row( diff --git a/lib/src/screens/explore/user_screen.dart b/lib/src/screens/explore/user_screen.dart index a9973dd1..b0ac0d66 100644 --- a/lib/src/screens/explore/user_screen.dart +++ b/lib/src/screens/explore/user_screen.dart @@ -38,14 +38,16 @@ enum UserFeedType { thread, microblog, comment, reply, follower, following } @RoutePage() class UserScreen extends StatefulWidget { - const UserScreen( - @PathParam('userId') this.userId, { + const UserScreen({ + @PathParam('username') required this.username, + this.userId, super.key, this.initData, this.onUpdate, }); - final int userId; + final String username; + final int? userId; final DetailedUserModel? initData; final void Function(DetailedUserModel)? onUpdate; @@ -76,11 +78,11 @@ class _UserScreenState extends State { _sort = context.read().profile.feedDefaultExploreSort; if (_data == null) { - context - .read() - .api - .users - .get(widget.userId) + (widget.userId == null + ? context.read().api.users.getByName( + widget.username, + ) + : context.read().api.users.get(widget.userId!)) .then((value) async { if (!context.mounted) return value; diff --git a/lib/src/screens/feed/nav_drawer.dart b/lib/src/screens/feed/nav_drawer.dart index a496a611..dcb08ddd 100644 --- a/lib/src/screens/feed/nav_drawer.dart +++ b/lib/src/screens/feed/nav_drawer.dart @@ -193,7 +193,11 @@ class _NavDrawerState extends State { if (!context.mounted) return; context.router.push( - UserRoute(userId: user.id, initData: user), + UserRoute( + username: user.name, + userId: user.id, + initData: user, + ), ); case '!': @@ -371,6 +375,7 @@ class _NavDrawerState extends State { ), onTap: () => context.router.push( UserRoute( + username: user.name, userId: user.id, initData: user, onUpdate: (newValue) => setState(() { diff --git a/lib/src/widgets/content_item/content_info.dart b/lib/src/widgets/content_item/content_info.dart index 4411f15c..2df3d7f6 100644 --- a/lib/src/widgets/content_item/content_info.dart +++ b/lib/src/widgets/content_item/content_info.dart @@ -148,8 +148,9 @@ class ContentInfo extends StatelessWidget { user!.name, displayName: user!.displayName, icon: user!.avatar, - onTap: () => - context.router.push(UserRoute(userId: user!.id)), + onTap: () => context.router.push( + UserRoute(username: user!.name, userId: user!.id), + ), ), ), UserStatusIcons(cakeDay: user!.createdAt, isBot: user!.isBot), diff --git a/lib/src/widgets/markdown/markdown_mention.dart b/lib/src/widgets/markdown/markdown_mention.dart index 43ee0516..4c4938ff 100644 --- a/lib/src/widgets/markdown/markdown_mention.dart +++ b/lib/src/widgets/markdown/markdown_mention.dart @@ -177,8 +177,9 @@ class MentionWidgetState extends State { setState(() { _icon = user.avatar; - _onClick = () => - context.router.push(UserRoute(userId: user.id, initData: user)); + _onClick = () => context.router.push( + UserRoute(username: user.name, userId: user.id, initData: user), + ); }); } else if (modifier == '!') { if (!communityMentionCache.containsKey(cacheKey)) { diff --git a/lib/src/widgets/menus/user_menu.dart b/lib/src/widgets/menus/user_menu.dart index adec7cfe..587de01b 100644 --- a/lib/src/widgets/menus/user_menu.dart +++ b/lib/src/widgets/menus/user_menu.dart @@ -89,8 +89,9 @@ Future showUserMenu( if (navigateOption) ContextMenuItem( title: l(context).openItem(user.name), - onTap: () => - context.router.push(UserRoute(userId: user.id, initData: user)), + onTap: () => context.router.push( + UserRoute(username: user.name, userId: user.id, initData: user), + ), ), ContextMenuItem( title: l(context).feeds_addTo, diff --git a/lib/src/widgets/tags/tag_screen.dart b/lib/src/widgets/tags/tag_screen.dart index 4e9a90e1..9a6519dd 100644 --- a/lib/src/widgets/tags/tag_screen.dart +++ b/lib/src/widgets/tags/tag_screen.dart @@ -244,7 +244,11 @@ class TagUsersScreenState extends State { unawaited( context.router.push( - UserRoute(userId: user.id, initData: user), + UserRoute( + username: user.name, + userId: user.id, + initData: user, + ), ), ); }, From 4c84b3a8e166f65053ec58fddbad20c12c63f18a Mon Sep 17 00:00:00 2001 From: olorin99 Date: Mon, 23 Feb 2026 14:41:12 +1000 Subject: [PATCH 3/8] Switch community path to use name as identifier. --- lib/src/controller/router.dart | 8 ++--- .../notification/notification_item.dart | 1 + lib/src/screens/explore/community_screen.dart | 29 ++++++++++++------- .../screens/explore/explore_screen_item.dart | 7 ++++- lib/src/screens/explore/mod_log.dart | 18 +++++++++--- lib/src/screens/feed/create_screen.dart | 1 + lib/src/screens/feed/nav_drawer.dart | 2 ++ lib/src/screens/settings/about_screen.dart | 2 ++ lib/src/widgets/community_picker.dart | 1 + .../widgets/content_item/content_info.dart | 5 +++- .../widgets/markdown/markdown_mention.dart | 6 +++- lib/src/widgets/menus/community_menu.dart | 2 ++ lib/src/widgets/menus/user_menu.dart | 4 ++- 13 files changed, 63 insertions(+), 23 deletions(-) diff --git a/lib/src/controller/router.dart b/lib/src/controller/router.dart index 39003fb0..941f672d 100644 --- a/lib/src/controller/router.dart +++ b/lib/src/controller/router.dart @@ -30,18 +30,18 @@ class AppRouter extends RootStackRouter { path: 'user/:username/message', ), - AutoRoute(page: CommunityRoute.page, path: 'community/:communityId'), + AutoRoute(page: CommunityRoute.page, path: 'community/:communityName'), AutoRoute( page: ModLogCommunityRoute.page, - path: 'community/:communityId/modlog', + path: 'community/:communityName/modlog', ), AutoRoute( page: CommunityModPanelRoute.page, - path: 'community/:communityId/mod', + path: 'community/:communityName/mod', ), AutoRoute( page: CommunityOwnerPanelRoute.page, - path: 'community/:communityId/owner', + path: 'community/:communityName/owner', ), AutoRoute(page: ModLogRoute.page, path: 'modlog'), diff --git a/lib/src/screens/account/notification/notification_item.dart b/lib/src/screens/account/notification/notification_item.dart index e744262a..94fa1d6f 100644 --- a/lib/src/screens/account/notification/notification_item.dart +++ b/lib/src/screens/account/notification/notification_item.dart @@ -211,6 +211,7 @@ class _NotificationItemState extends State { icon: bannedCommunity.icon, onTap: () => context.router.push( CommunityRoute( + communityName: bannedCommunity.name, communityId: bannedCommunity.id, ), ), diff --git a/lib/src/screens/explore/community_screen.dart b/lib/src/screens/explore/community_screen.dart index 998542a5..20ca210f 100644 --- a/lib/src/screens/explore/community_screen.dart +++ b/lib/src/screens/explore/community_screen.dart @@ -22,14 +22,16 @@ import 'package:provider/provider.dart'; @RoutePage() class CommunityScreen extends StatefulWidget { - const CommunityScreen( - @PathParam('communityId') this.communityId, { + const CommunityScreen({ + @PathParam('communityName') required this.communityName, + this.communityId, super.key, this.initData, this.onUpdate, }); - final int communityId; + final String communityName; + final int? communityId; final DetailedCommunityModel? initData; final void Function(DetailedCommunityModel)? onUpdate; @@ -47,14 +49,19 @@ class _CommunityScreenState extends State { _data = widget.initData; if (_data == null) { - context.read().api.community.get(widget.communityId).then(( - value, - ) { - if (!mounted) return; - setState(() { - _data = value; - }); - }); + (widget.communityId == null + ? context.read().api.community.getByName( + widget.communityName, + ) + : context.read().api.community.get( + widget.communityId!, + )) + .then((value) { + if (!mounted) return; + setState(() { + _data = value; + }); + }); } } diff --git a/lib/src/screens/explore/explore_screen_item.dart b/lib/src/screens/explore/explore_screen_item.dart index b57f8be6..a2b2d951 100644 --- a/lib/src/screens/explore/explore_screen_item.dart +++ b/lib/src/screens/explore/explore_screen_item.dart @@ -111,7 +111,12 @@ class ExploreScreenItem extends StatelessWidget { }; final navigate = switch (item) { final DetailedCommunityModel i => () => context.router.push( - CommunityRoute(communityId: i.id, initData: i, onUpdate: onUpdate), + CommunityRoute( + communityName: i.name, + communityId: i.id, + initData: i, + onUpdate: onUpdate, + ), ), final DetailedUserModel i => () => context.router.push( UserRoute( diff --git a/lib/src/screens/explore/mod_log.dart b/lib/src/screens/explore/mod_log.dart index 4f5bce97..00bf0f3e 100644 --- a/lib/src/screens/explore/mod_log.dart +++ b/lib/src/screens/explore/mod_log.dart @@ -19,10 +19,12 @@ import 'package:provider/provider.dart'; @RoutePage() class ModLogCommunityScreen extends StatelessWidget { const ModLogCommunityScreen({ - @PathParam('communityId') required this.communityId, + @PathParam('communityName') required this.communityName, + required this.communityId, super.key, }); + final String communityName; final int communityId; @override @@ -32,10 +34,12 @@ class ModLogCommunityScreen extends StatelessWidget { @RoutePage() class ModLogUserScreen extends StatelessWidget { const ModLogUserScreen({ - @PathParam('userId') required this.userId, + @PathParam('username') required this.username, + required this.userId, super.key, }); + final String username; final int userId; @override @@ -196,10 +200,16 @@ class _ModLogScreenState extends State { UserRoute(username: item.user!.name, userId: item.user!.id), ), ModLogType.communityAdded => () => context.router.push( - CommunityRoute(communityId: item.community.id), + CommunityRoute( + communityName: item.community.name, + communityId: item.community.id, + ), ), ModLogType.communityRemoved => () => context.router.push( - CommunityRoute(communityId: item.community.id), + CommunityRoute( + communityName: item.community.name, + communityId: item.community.id, + ), ), ModLogType.postLocked => item.postId == null diff --git a/lib/src/screens/feed/create_screen.dart b/lib/src/screens/feed/create_screen.dart index cd52ed04..2512a84b 100644 --- a/lib/src/screens/feed/create_screen.dart +++ b/lib/src/screens/feed/create_screen.dart @@ -601,6 +601,7 @@ class _CreateScreenState extends State { context.router.pop(); context.router.push( CommunityRoute( + communityName: newCommunity.name, communityId: newCommunity.id, initData: newCommunity, ), diff --git a/lib/src/screens/feed/nav_drawer.dart b/lib/src/screens/feed/nav_drawer.dart index dcb08ddd..4f027aa3 100644 --- a/lib/src/screens/feed/nav_drawer.dart +++ b/lib/src/screens/feed/nav_drawer.dart @@ -207,6 +207,7 @@ class _NavDrawerState extends State { context.router.push( CommunityRoute( + communityName: community.name, communityId: community.id, initData: community, ), @@ -303,6 +304,7 @@ class _NavDrawerState extends State { ), onTap: () => context.router.push( CommunityRoute( + communityName: community.name, communityId: community.id, initData: community, onUpdate: (newValue) => setState(() { diff --git a/lib/src/screens/settings/about_screen.dart b/lib/src/screens/settings/about_screen.dart index 3132281f..c907e1e9 100644 --- a/lib/src/screens/settings/about_screen.dart +++ b/lib/src/screens/settings/about_screen.dart @@ -96,6 +96,7 @@ class _AboutScreenState extends State { context.router.push( CommunityRoute( + communityName: community.name, communityId: community.id, initData: community, ), @@ -126,6 +127,7 @@ class _AboutScreenState extends State { context.router.push( CommunityRoute( + communityName: community.name, communityId: community.id, initData: community, ), diff --git a/lib/src/widgets/community_picker.dart b/lib/src/widgets/community_picker.dart index 25eaf857..f96266da 100644 --- a/lib/src/widgets/community_picker.dart +++ b/lib/src/widgets/community_picker.dart @@ -48,6 +48,7 @@ class _CommunityPickerState extends State { : IconButton( onPressed: () => context.router.push( CommunityRoute( + communityName: widget.value!.name, communityId: widget.value!.id, initData: widget.value, onUpdate: (newValue) => widget.onChange(newValue), diff --git a/lib/src/widgets/content_item/content_info.dart b/lib/src/widgets/content_item/content_info.dart index 2df3d7f6..194ffe2b 100644 --- a/lib/src/widgets/content_item/content_info.dart +++ b/lib/src/widgets/content_item/content_info.dart @@ -180,7 +180,10 @@ class ContentInfo extends StatelessWidget { community!.name, icon: community!.icon, onTap: () => context.router.push( - CommunityRoute(communityId: community!.id), + CommunityRoute( + communityName: community!.name, + communityId: community!.id, + ), ), ), ); diff --git a/lib/src/widgets/markdown/markdown_mention.dart b/lib/src/widgets/markdown/markdown_mention.dart index 4c4938ff..ad009d24 100644 --- a/lib/src/widgets/markdown/markdown_mention.dart +++ b/lib/src/widgets/markdown/markdown_mention.dart @@ -198,7 +198,11 @@ class MentionWidgetState extends State { setState(() { _icon = community.icon; _onClick = () => context.router.push( - CommunityRoute(communityId: community.id, initData: community), + CommunityRoute( + communityName: community.name, + communityId: community.id, + initData: community, + ), ); }); } diff --git a/lib/src/widgets/menus/community_menu.dart b/lib/src/widgets/menus/community_menu.dart index 4719088e..09905a51 100644 --- a/lib/src/widgets/menus/community_menu.dart +++ b/lib/src/widgets/menus/community_menu.dart @@ -91,6 +91,7 @@ Future showCommunityMenu( title: l(context).openItem(name), onTap: () => context.router.push( CommunityRoute( + communityName: detailedCommunity?.name ?? community!.name, communityId: detailedCommunity?.id ?? community!.id, initData: detailedCommunity, ), @@ -166,6 +167,7 @@ Future showCommunityMenu( title: l(context).modlog, onTap: () => context.router.push( ModLogCommunityRoute( + communityName: detailedCommunity?.name ?? community!.name, communityId: detailedCommunity?.id ?? community!.id, ), ), diff --git a/lib/src/widgets/menus/user_menu.dart b/lib/src/widgets/menus/user_menu.dart index 587de01b..98ab47d0 100644 --- a/lib/src/widgets/menus/user_menu.dart +++ b/lib/src/widgets/menus/user_menu.dart @@ -127,7 +127,9 @@ Future showUserMenu( if (ac.serverSoftware == ServerSoftware.lemmy) ContextMenuItem( title: l(context).modlog, - onTap: () => context.router.push(ModLogUserRoute(userId: user.id)), + onTap: () => context.router.push( + ModLogUserRoute(username: user.name, userId: user.id), + ), ), ], ).openMenu(context); From 87e6735724e8895f9c316006b32ccd666172bf9a Mon Sep 17 00:00:00 2001 From: olorin99 Date: Tue, 24 Feb 2026 14:04:51 +1000 Subject: [PATCH 4/8] Move /thread /microblog paths under community. --- lib/src/controller/router.dart | 4 ++-- lib/src/screens/explore/bookmarks_screen.dart | 1 + lib/src/screens/explore/community_mod_panel.dart | 1 + lib/src/screens/explore/explore_screen_item.dart | 1 + lib/src/screens/explore/mod_log.dart | 8 ++++++++ lib/src/screens/explore/user_screen.dart | 1 + lib/src/screens/feed/feed_screen.dart | 1 + lib/src/screens/feed/post_comment_screen.dart | 1 + lib/src/screens/feed/post_page.dart | 11 +++++++++-- 9 files changed, 25 insertions(+), 4 deletions(-) diff --git a/lib/src/controller/router.dart b/lib/src/controller/router.dart index 941f672d..ff5817bb 100644 --- a/lib/src/controller/router.dart +++ b/lib/src/controller/router.dart @@ -18,8 +18,8 @@ class AppRouter extends RootStackRouter { AutoRoute(page: FeedRoute.page, path: 'feed'), AutoRoute(page: ExploreRoute.page, path: 'explore'), - AutoRoute(page: ThreadRoute.page, path: 'thread/:id'), - AutoRoute(page: MicroblogRoute.page, path: 'microblog/:id'), + AutoRoute(page: ThreadRoute.page, path: 'community/:communityName/thread/:id'), + AutoRoute(page: MicroblogRoute.page, path: 'community/:communityName/microblog/:id'), AutoRoute(page: PostCommentRoute.page, path: 'comment/:id'), AutoRoute(page: ContentReplyRoute.page, path: 'reply'), diff --git a/lib/src/screens/explore/bookmarks_screen.dart b/lib/src/screens/explore/bookmarks_screen.dart index 955e127f..6064563c 100644 --- a/lib/src/screens/explore/bookmarks_screen.dart +++ b/lib/src/screens/explore/bookmarks_screen.dart @@ -205,6 +205,7 @@ class _BookmarksScreenState extends State { _pagingController.updateItem(newValue.id, newValue), onTap: () => pushPostPage( context, + communityName: item.community.name, postId: item.id, postType: item.type, initData: item, diff --git a/lib/src/screens/explore/community_mod_panel.dart b/lib/src/screens/explore/community_mod_panel.dart index b0be340a..14f4f647 100644 --- a/lib/src/screens/explore/community_mod_panel.dart +++ b/lib/src/screens/explore/community_mod_panel.dart @@ -226,6 +226,7 @@ class _MagazineModPanelReportsState extends State { if (item.subjectPost != null) { pushPostPage( context, + communityName: item.subjectPost!.community.name, postId: item.subjectPost!.id, postType: item.subjectPost!.type, initData: item.subjectPost, diff --git a/lib/src/screens/explore/explore_screen_item.dart b/lib/src/screens/explore/explore_screen_item.dart index a2b2d951..944f6051 100644 --- a/lib/src/screens/explore/explore_screen_item.dart +++ b/lib/src/screens/explore/explore_screen_item.dart @@ -205,6 +205,7 @@ class ExploreScreenItem extends StatelessWidget { child: InkWell( onTap: () => pushPostPage( context, + communityName: item.community.name, postId: item.id, postType: item.type, initData: item, diff --git a/lib/src/screens/explore/mod_log.dart b/lib/src/screens/explore/mod_log.dart index 00bf0f3e..37baff84 100644 --- a/lib/src/screens/explore/mod_log.dart +++ b/lib/src/screens/explore/mod_log.dart @@ -96,6 +96,7 @@ class _ModLogScreenState extends State { ? null : () => pushPostPage( context, + communityName: item.community.name, postId: item.postId, postType: PostType.thread, ), @@ -104,6 +105,7 @@ class _ModLogScreenState extends State { ? null : () => pushPostPage( context, + communityName: item.community.name, postId: item.postId, postType: PostType.thread, ), @@ -130,6 +132,7 @@ class _ModLogScreenState extends State { ? null : () => pushPostPage( context, + communityName: item.community.name, postId: item.postId, postType: PostType.thread, ), @@ -138,6 +141,7 @@ class _ModLogScreenState extends State { ? null : () => pushPostPage( context, + communityName: item.community.name, postId: item.postId, postType: PostType.thread, ), @@ -146,6 +150,7 @@ class _ModLogScreenState extends State { ? null : () => pushPostPage( context, + communityName: item.community.name, postId: item.postId, postType: PostType.thread, ), @@ -154,6 +159,7 @@ class _ModLogScreenState extends State { ? null : () => pushPostPage( context, + communityName: item.community.name, postId: item.postId, postType: PostType.thread, ), @@ -216,6 +222,7 @@ class _ModLogScreenState extends State { ? null : () => pushPostPage( context, + communityName: item.community.name, postId: item.postId, postType: PostType.thread, ), @@ -224,6 +231,7 @@ class _ModLogScreenState extends State { ? null : () => pushPostPage( context, + communityName: item.community.name, postId: item.postId, postType: PostType.thread, ), diff --git a/lib/src/screens/explore/user_screen.dart b/lib/src/screens/explore/user_screen.dart index b0ac0d66..229bb7e8 100644 --- a/lib/src/screens/explore/user_screen.dart +++ b/lib/src/screens/explore/user_screen.dart @@ -628,6 +628,7 @@ class _UserScreenBodyState extends State (newValue) => _pagingController.updateItem(item, newValue), onTap: () => pushPostPage( context, + communityName: item.community.name, postId: item.id, postType: item.type, initData: item, diff --git a/lib/src/screens/feed/feed_screen.dart b/lib/src/screens/feed/feed_screen.dart index 15853585..9608573f 100644 --- a/lib/src/screens/feed/feed_screen.dart +++ b/lib/src/screens/feed/feed_screen.dart @@ -850,6 +850,7 @@ class _FeedScreenBodyState extends State void onPostTap() { pushPostPage( context, + communityName: item.community.name, initData: item, userCanModerate: widget.userCanModerate, onUpdate: (newValue) => diff --git a/lib/src/screens/feed/post_comment_screen.dart b/lib/src/screens/feed/post_comment_screen.dart index cbf11f2b..810313bc 100644 --- a/lib/src/screens/feed/post_comment_screen.dart +++ b/lib/src/screens/feed/post_comment_screen.dart @@ -70,6 +70,7 @@ class _PostCommentScreenState extends State { child: OutlinedButton( onPressed: () => pushPostPage( context, + communityName: comment.community.name, postId: comment.postId, postType: comment.postType, ), diff --git a/lib/src/screens/feed/post_page.dart b/lib/src/screens/feed/post_page.dart index fccababd..7a72ebfe 100644 --- a/lib/src/screens/feed/post_page.dart +++ b/lib/src/screens/feed/post_page.dart @@ -26,6 +26,7 @@ import 'package:provider/provider.dart'; @RoutePage() class ThreadPage extends StatelessWidget { const ThreadPage({ + @PathParam('communityName') this.communityName, @PathParam('id') required this.postId, super.key, this.initData, @@ -33,6 +34,7 @@ class ThreadPage extends StatelessWidget { this.userCanModerate = false, }); + final String? communityName; final int postId; final PostModel? initData; final void Function(PostModel)? onUpdate; @@ -51,6 +53,7 @@ class ThreadPage extends StatelessWidget { @RoutePage() class MicroblogPage extends StatelessWidget { const MicroblogPage({ + @PathParam('communityName') this.communityName, @PathParam('id') required this.postId, super.key, this.initData, @@ -58,6 +61,7 @@ class MicroblogPage extends StatelessWidget { this.userCanModerate = false, }); + final String? communityName; final int postId; final PostModel? initData; final void Function(PostModel)? onUpdate; @@ -75,6 +79,7 @@ class MicroblogPage extends StatelessWidget { Future pushPostPage( BuildContext context, { + String? communityName, int? postId, PostType? postType, PostModel? initData, @@ -87,12 +92,14 @@ Future pushPostPage( context.router.push( type == PostType.thread ? ThreadRoute( + communityName: communityName, postId: id, initData: initData, userCanModerate: userCanModerate, onUpdate: onUpdate, ) : MicroblogRoute( + communityName: communityName, postId: id, initData: initData, userCanModerate: userCanModerate, @@ -567,7 +574,7 @@ class _PostPageState extends State { context, ).commentsX(crossPost.numComments), onTap: () async => - pushPostPage(context, initData: crossPost), + pushPostPage(context, communityName: crossPost.community.name, initData: crossPost), ), ) .toList(), @@ -610,7 +617,7 @@ class _PostPageState extends State { icon: const Icon(Symbols.more_vert_rounded), ), onTap: () => - pushPostPage(context, initData: crossPost), + pushPostPage(context, communityName: crossPost.community.name, initData: crossPost), onLongPress: () => showCrossPostMenu(context, crossPost), ), From 0c1e3f091dd8c768d4869135452c8c27f7327dd6 Mon Sep 17 00:00:00 2001 From: olorin99 Date: Tue, 24 Feb 2026 14:20:48 +1000 Subject: [PATCH 5/8] Allow setting default instance by environment variables. --- lib/src/controller/controller.dart | 14 +++++++------- lib/src/controller/database/database.dart | 13 +++++++++++-- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/lib/src/controller/controller.dart b/lib/src/controller/controller.dart index 115a4731..fd186a98 100644 --- a/lib/src/controller/controller.dart +++ b/lib/src/controller/controller.dart @@ -236,10 +236,10 @@ class AppController with ChangeNotifier { ); if (_servers.isEmpty || _accounts.isEmpty || _selectedAccount.isEmpty) { - await saveServer(ServerSoftware.mbin, 'kbin.earth'); + await saveServer(defaultSoftware, defaultInstance); await setAccount( - '@kbin.earth', - const Account(handle: '@kbin.earth', isPushRegistered: false), + defaultAccount, + const Account(handle: defaultAccount, isPushRegistered: false), switchNow: true, ); } @@ -607,7 +607,7 @@ class AppController with ChangeNotifier { _rebuildProfile(); _accounts.remove(key); - _selectedAccount = _accounts.keys.firstOrNull ?? '@kbin.earth'; + _selectedAccount = _accounts.keys.firstOrNull ?? defaultAccount; // If there are no accounts left from a server, then remove the server's data final keyAccountServer = key.split('@').last; @@ -634,10 +634,10 @@ class AppController with ChangeNotifier { // Ensure default guest account remains if (_servers.isEmpty || _accounts.isEmpty || _selectedAccount.isEmpty) { - await saveServer(ServerSoftware.mbin, 'kbin.earth'); + await saveServer(defaultSoftware, defaultInstance); await setAccount( - '@kbin.earth', - const Account(handle: '@kbin.earth', isPushRegistered: false), + defaultAccount, + const Account(handle: defaultAccount, isPushRegistered: false), switchNow: true, ); } diff --git a/lib/src/controller/database/database.dart b/lib/src/controller/database/database.dart index 58930459..715ff151 100644 --- a/lib/src/controller/database/database.dart +++ b/lib/src/controller/database/database.dart @@ -30,6 +30,15 @@ import 'package:sembast/sembast_io.dart'; part 'database.g.dart'; +final ServerSoftware defaultSoftware = ServerSoftware.values.byName( + const String.fromEnvironment('defaultSoftware', defaultValue: 'mbin'), +); +const defaultInstance = String.fromEnvironment( + 'defaultInstance', + defaultValue: 'kbin.earth', +); +const defaultAccount = '@$defaultInstance'; + class CredentialsConverter extends TypeConverter with JsonTypeConverter2 { const CredentialsConverter(); @@ -58,7 +67,7 @@ class CredentialsConverter extends TypeConverter @TableIndex(name: 'account_unifiedpushToken', columns: {#unifiedpushToken}) class Accounts extends Table { TextColumn get handle => - text().withLength(min: 1).clientDefault(() => '@kbin.earth')(); + text().withLength(min: 1).clientDefault(() => defaultAccount)(); TextColumn get oauth => text().map(const CredentialsConverter()).nullable()(); TextColumn get jwt => text().nullable()(); BoolColumn get isPushRegistered => @@ -363,7 +372,7 @@ class MiscCache extends Table { )(); TextColumn get selectedAccount => text() .references(Accounts, #handle, onDelete: KeyAction.setDefault) - .clientDefault(() => '@kbin.earth')(); + .clientDefault(() => defaultAccount)(); TextColumn get webPushKeys => text().nullable()(); TextColumn get downloadsDir => text().nullable()(); BoolColumn get expandNavDrawer => From 4d73b9c237201ec20a9b53950b28783261281f64 Mon Sep 17 00:00:00 2001 From: olorin99 Date: Tue, 24 Feb 2026 14:20:54 +1000 Subject: [PATCH 6/8] Format --- lib/src/controller/router.dart | 10 ++++++++-- lib/src/screens/explore/mod_log.dart | 14 +++++++------- lib/src/screens/feed/post_page.dart | 14 ++++++++++---- 3 files changed, 25 insertions(+), 13 deletions(-) diff --git a/lib/src/controller/router.dart b/lib/src/controller/router.dart index ff5817bb..a04586b7 100644 --- a/lib/src/controller/router.dart +++ b/lib/src/controller/router.dart @@ -18,8 +18,14 @@ class AppRouter extends RootStackRouter { AutoRoute(page: FeedRoute.page, path: 'feed'), AutoRoute(page: ExploreRoute.page, path: 'explore'), - AutoRoute(page: ThreadRoute.page, path: 'community/:communityName/thread/:id'), - AutoRoute(page: MicroblogRoute.page, path: 'community/:communityName/microblog/:id'), + AutoRoute( + page: ThreadRoute.page, + path: 'community/:communityName/thread/:id', + ), + AutoRoute( + page: MicroblogRoute.page, + path: 'community/:communityName/microblog/:id', + ), AutoRoute(page: PostCommentRoute.page, path: 'comment/:id'), AutoRoute(page: ContentReplyRoute.page, path: 'reply'), diff --git a/lib/src/screens/explore/mod_log.dart b/lib/src/screens/explore/mod_log.dart index 37baff84..68f690e6 100644 --- a/lib/src/screens/explore/mod_log.dart +++ b/lib/src/screens/explore/mod_log.dart @@ -105,7 +105,7 @@ class _ModLogScreenState extends State { ? null : () => pushPostPage( context, - communityName: item.community.name, + communityName: item.community.name, postId: item.postId, postType: PostType.thread, ), @@ -132,7 +132,7 @@ class _ModLogScreenState extends State { ? null : () => pushPostPage( context, - communityName: item.community.name, + communityName: item.community.name, postId: item.postId, postType: PostType.thread, ), @@ -141,7 +141,7 @@ class _ModLogScreenState extends State { ? null : () => pushPostPage( context, - communityName: item.community.name, + communityName: item.community.name, postId: item.postId, postType: PostType.thread, ), @@ -150,7 +150,7 @@ class _ModLogScreenState extends State { ? null : () => pushPostPage( context, - communityName: item.community.name, + communityName: item.community.name, postId: item.postId, postType: PostType.thread, ), @@ -159,7 +159,7 @@ class _ModLogScreenState extends State { ? null : () => pushPostPage( context, - communityName: item.community.name, + communityName: item.community.name, postId: item.postId, postType: PostType.thread, ), @@ -222,7 +222,7 @@ class _ModLogScreenState extends State { ? null : () => pushPostPage( context, - communityName: item.community.name, + communityName: item.community.name, postId: item.postId, postType: PostType.thread, ), @@ -231,7 +231,7 @@ class _ModLogScreenState extends State { ? null : () => pushPostPage( context, - communityName: item.community.name, + communityName: item.community.name, postId: item.postId, postType: PostType.thread, ), diff --git a/lib/src/screens/feed/post_page.dart b/lib/src/screens/feed/post_page.dart index 7a72ebfe..99fc0903 100644 --- a/lib/src/screens/feed/post_page.dart +++ b/lib/src/screens/feed/post_page.dart @@ -573,8 +573,11 @@ class _PostPageState extends State { subtitle: l( context, ).commentsX(crossPost.numComments), - onTap: () async => - pushPostPage(context, communityName: crossPost.community.name, initData: crossPost), + onTap: () async => pushPostPage( + context, + communityName: crossPost.community.name, + initData: crossPost, + ), ), ) .toList(), @@ -616,8 +619,11 @@ class _PostPageState extends State { showCrossPostMenu(context, crossPost), icon: const Icon(Symbols.more_vert_rounded), ), - onTap: () => - pushPostPage(context, communityName: crossPost.community.name, initData: crossPost), + onTap: () => pushPostPage( + context, + communityName: crossPost.community.name, + initData: crossPost, + ), onLongPress: () => showCrossPostMenu(context, crossPost), ), From 0501d385072de66de4762feace15ac06dd11f632 Mon Sep 17 00:00:00 2001 From: olorin99 Date: Tue, 24 Feb 2026 14:33:22 +1000 Subject: [PATCH 7/8] Shorten routes. /user -> /u /community -> /c --- lib/src/controller/router.dart | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/lib/src/controller/router.dart b/lib/src/controller/router.dart index a04586b7..e01a892d 100644 --- a/lib/src/controller/router.dart +++ b/lib/src/controller/router.dart @@ -20,34 +20,34 @@ class AppRouter extends RootStackRouter { AutoRoute( page: ThreadRoute.page, - path: 'community/:communityName/thread/:id', + path: 'c/:communityName/thread/:id', ), AutoRoute( page: MicroblogRoute.page, - path: 'community/:communityName/microblog/:id', + path: 'c/:communityName/microblog/:id', ), AutoRoute(page: PostCommentRoute.page, path: 'comment/:id'), AutoRoute(page: ContentReplyRoute.page, path: 'reply'), - AutoRoute(page: UserRoute.page, path: 'user/:username'), - AutoRoute(page: ModLogUserRoute.page, path: 'user/:username/modlog'), + AutoRoute(page: UserRoute.page, path: 'u/:username'), + AutoRoute(page: ModLogUserRoute.page, path: 'u/:username/modlog'), AutoRoute( page: MessageThreadRoute.page, - path: 'user/:username/message', + path: 'u/:username/message', ), - AutoRoute(page: CommunityRoute.page, path: 'community/:communityName'), + AutoRoute(page: CommunityRoute.page, path: 'c/:communityName'), AutoRoute( page: ModLogCommunityRoute.page, - path: 'community/:communityName/modlog', + path: 'c/:communityName/modlog', ), AutoRoute( page: CommunityModPanelRoute.page, - path: 'community/:communityName/mod', + path: 'c/:communityName/mod', ), AutoRoute( page: CommunityOwnerPanelRoute.page, - path: 'community/:communityName/owner', + path: 'c/:communityName/owner', ), AutoRoute(page: ModLogRoute.page, path: 'modlog'), From 7d707d3a327bad6e0cfe56117d29891d25d34b2f Mon Sep 17 00:00:00 2001 From: olorin99 Date: Tue, 24 Feb 2026 15:17:27 +1000 Subject: [PATCH 8/8] Fix instance redirect. Fix null on navigating to community page. --- lib/src/app.dart | 10 +--------- lib/src/controller/router.dart | 11 +++-------- lib/src/screens/explore/community_screen.dart | 4 +++- 3 files changed, 7 insertions(+), 18 deletions(-) diff --git a/lib/src/app.dart b/lib/src/app.dart index c22efc53..6188c714 100644 --- a/lib/src/app.dart +++ b/lib/src/app.dart @@ -1,4 +1,3 @@ -import 'package:auto_route/auto_route.dart'; import 'package:dynamic_color/dynamic_color.dart'; import 'package:flex_color_scheme/flex_color_scheme.dart'; import 'package:flutter/material.dart'; @@ -6,7 +5,6 @@ import 'package:flutter_localized_locales/flutter_localized_locales.dart'; import 'package:interstellar/l10n/app_localizations.dart'; import 'package:interstellar/src/controller/controller.dart'; import 'package:interstellar/src/controller/router.dart'; -import 'package:interstellar/src/controller/router.gr.dart'; import 'package:interstellar/src/screens/account/notification/notification_count_controller.dart'; import 'package:interstellar/src/utils/globals.dart'; import 'package:interstellar/src/utils/utils.dart'; @@ -47,13 +45,7 @@ class App extends StatelessWidget { textScaler: TextScaler.linear(ac.profile.globalTextScale), ), child: MaterialApp.router( - routerConfig: router.config( - deepLinkBuilder: (deepLink) { - return DeepLink([ - AppInstanceRoute(instance: ac.instanceHost), - ]); - }, - ), + routerConfig: router.config(), restorationScopeId: 'app', localizationsDelegates: const [ ...AppLocalizations.localizationsDelegates, diff --git a/lib/src/controller/router.dart b/lib/src/controller/router.dart index e01a892d..f5618dcb 100644 --- a/lib/src/controller/router.dart +++ b/lib/src/controller/router.dart @@ -18,10 +18,7 @@ class AppRouter extends RootStackRouter { AutoRoute(page: FeedRoute.page, path: 'feed'), AutoRoute(page: ExploreRoute.page, path: 'explore'), - AutoRoute( - page: ThreadRoute.page, - path: 'c/:communityName/thread/:id', - ), + AutoRoute(page: ThreadRoute.page, path: 'c/:communityName/thread/:id'), AutoRoute( page: MicroblogRoute.page, path: 'c/:communityName/microblog/:id', @@ -31,10 +28,7 @@ class AppRouter extends RootStackRouter { AutoRoute(page: UserRoute.page, path: 'u/:username'), AutoRoute(page: ModLogUserRoute.page, path: 'u/:username/modlog'), - AutoRoute( - page: MessageThreadRoute.page, - path: 'u/:username/message', - ), + AutoRoute(page: MessageThreadRoute.page, path: 'u/:username/message'), AutoRoute(page: CommunityRoute.page, path: 'c/:communityName'), AutoRoute( @@ -64,6 +58,7 @@ class AppRouter extends RootStackRouter { AutoRoute(page: EditFeedRoute.page, path: 'feed/:feed/edit'), ], ), + RedirectRoute(path: '/', redirectTo: '/$defaultInstance'), //settings AutoRoute(page: BehaviorSettingsRoute.page, path: '/settings/behavior'), diff --git a/lib/src/screens/explore/community_screen.dart b/lib/src/screens/explore/community_screen.dart index 20ca210f..6e322343 100644 --- a/lib/src/screens/explore/community_screen.dart +++ b/lib/src/screens/explore/community_screen.dart @@ -69,6 +69,8 @@ class _CommunityScreenState extends State { Widget build(BuildContext context) { final ac = context.watch(); + if (_data == null) return Container(); + final globalName = _data == null ? null : _data!.name.contains('@') @@ -79,7 +81,7 @@ class _CommunityScreenState extends State { feed: FeedAggregator.fromSingleSource( name: _data?.name ?? '', source: FeedSource.community, - sourceId: widget.communityId, + sourceId: _data?.id, ), createPostCommunity: _data, details: _data == null