Compare commits

...
1 Commits
Author SHA1 Message Date
Jeroen SchweitzerandClaude Opus 4.5 40ba6a869d fix: apply default room preference on app load
Build and Push / release (push) Successful in 3s
Build and Push / build (push) Successful in 3m7s
- Root `/` now redirects to user's preferred default room
- Front Hall moved to `/front-hall` route (was `/`)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-05 15:00:47 +01:00
3 changed files with 37 additions and 3 deletions
+7
View File
@@ -7,6 +7,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased] ## [Unreleased]
## [1.3.1] - 2026-01-05
### Fixed
- Default room preference now applies on app load
- Root `/` redirects to user's preferred default room
- Front Hall moved to `/front-hall` route (was `/`)
## [1.3.0] - 2026-01-05 ## [1.3.0] - 2026-01-05
### Added ### Added
+29 -2
View File
@@ -1,6 +1,7 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart'; import 'package:go_router/go_router.dart';
import 'package:riverpod_annotation/riverpod_annotation.dart'; import 'package:riverpod_annotation/riverpod_annotation.dart';
import 'package:tatlock_ui/core/auth/auth_provider.dart';
import 'package:tatlock_ui/features/control_room/router.dart'; import 'package:tatlock_ui/features/control_room/router.dart';
import 'package:tatlock_ui/features/front_hall/presentation/pages/front_hall_page.dart'; import 'package:tatlock_ui/features/front_hall/presentation/pages/front_hall_page.dart';
import 'package:tatlock_ui/features/security/router.dart'; import 'package:tatlock_ui/features/security/router.dart';
@@ -19,18 +20,44 @@ Page<void> noTransitionPage(BuildContext context, GoRouterState state, Widget ch
/// Route paths as constants. /// Route paths as constants.
abstract class AppRoutes { abstract class AppRoutes {
static const frontHall = '/'; static const root = '/';
static const frontHall = '/front-hall';
static const parlor = '/parlor'; static const parlor = '/parlor';
static const settings = '/settings'; static const settings = '/settings';
} }
/// Maps defaultRoom preference value to route path.
String _routeForDefaultRoom(String? defaultRoom) {
return switch (defaultRoom) {
'control-room' => ControlRoomRoutes.containers,
'security' => SecurityRoutes.users,
'parlor' => AppRoutes.parlor,
_ => AppRoutes.frontHall,
};
}
/// Provides the GoRouter instance. /// Provides the GoRouter instance.
@riverpod @riverpod
GoRouter appRouter(Ref ref) { GoRouter appRouter(Ref ref) {
final authState = ref.watch(authProvider);
return GoRouter( return GoRouter(
initialLocation: AppRoutes.frontHall, initialLocation: AppRoutes.root,
debugLogDiagnostics: true, debugLogDiagnostics: true,
redirect: (context, state) {
// Redirect from root to user's default room preference
if (state.matchedLocation == AppRoutes.root) {
final defaultRoom = authState.value?.preferences?.defaultRoom;
return _routeForDefaultRoom(defaultRoom);
}
return null;
},
routes: [ routes: [
// Root redirects to default room (handled by redirect callback above)
GoRoute(
path: AppRoutes.root,
redirect: (context, state) => AppRoutes.frontHall,
),
// Main app routes (inside shell with app scaffold) // Main app routes (inside shell with app scaffold)
ShellRoute( ShellRoute(
builder: (context, state, child) => AppScaffold(child: child), builder: (context, state, child) => AppScaffold(child: child),
+1 -1
View File
@@ -16,7 +16,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
# In Windows, build-name is used as the major, minor, and patch parts # In Windows, build-name is used as the major, minor, and patch parts
# of the product and file versions while build-number is used as the build suffix. # of the product and file versions while build-number is used as the build suffix.
version: 1.3.0+1 version: 1.3.1+1
environment: environment:
sdk: ^3.10.4 sdk: ^3.10.4