feat: Implement default destination selection for SAR Update Sheet

- Added logic to set the default destination to the first available room, or the first channel if no rooms exist.
- This enhancement improves user experience by automatically selecting a relevant destination upon initialization.
This commit is contained in:
Janez T
2025-10-14 22:58:33 +02:00
parent 846cc9dce4
commit 05b90d7f1f
2 changed files with 1299 additions and 0 deletions

View File

@@ -627,6 +627,29 @@ class _SarUpdateSheetState extends State<_SarUpdateSheet> {
void initState() {
super.initState();
_getCurrentLocation();
_setDefaultDestination();
}
void _setDefaultDestination() {
// Set default to first room, or first channel if no rooms exist
WidgetsBinding.instance.addPostFrameCallback((_) {
final contactsProvider = context.read<ContactsProvider>();
final destinations = contactsProvider.roomsAndChannels;
if (destinations.isNotEmpty) {
// Prefer rooms over channels
final room = destinations.firstWhere(
(c) => c.isRoom,
orElse: () => destinations.first,
);
if (mounted) {
setState(() {
_selectedContact = room;
});
}
}
});
}
@override