mirror of
https://github.com/dz0ny/meshcore-sar.git
synced 2026-08-11 16:30:28 +00:00
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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user