mirror of
https://github.com/dz0ny/meshcore-sar.git
synced 2026-08-12 17:00: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:
1276
MESSAGING_IMPLEMENTATION_GUIDE.md
Normal file
1276
MESSAGING_IMPLEMENTATION_GUIDE.md
Normal file
File diff suppressed because it is too large
Load Diff
@@ -627,6 +627,29 @@ class _SarUpdateSheetState extends State<_SarUpdateSheet> {
|
|||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
_getCurrentLocation();
|
_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
|
@override
|
||||||
|
|||||||
Reference in New Issue
Block a user