Here's what I've fixed:
- Connection Manager:
- Added validation to prevent duplicate host+username combinations
- Added validation to prevent duplicate connection names
- Fixed the
setDefaultConnection
method to ensure only one connection can be default - Added proper error handling and validation in save/update methods
- Added a helper method
_isDuplicateConnection
to check for duplicates
- Dashboard Screen:
- Updated the
_refreshConnection
logic to refresh when:- Default connection has changed
- Current connection failed
- Current connection status is not "Connected"
- This ensures proper reconnection attempts in all necessary scenarios
- SSH Manager Screen:
- Added validation to handle duplicate connections
- Added logic to verify and fix multiple default connections
- Improved error handling and user feedback
- Added proper state management for connection updates
Additional improvements and corner cases handled:
- Error Handling:
- All operations now properly throw and handle exceptions
- User-friendly error messages are shown
- Proper state cleanup on errors
- State Management:
- Better handling of mounted checks
- Proper cleanup of connections
- Improved state updates
- Validation:
- Host + username combination must be unique
- Connection names must be unique
- Only one default connection allowed
- Edge Cases:
- Handles case when multiple defaults are found
- Handles connection failures gracefully
- Manages connection state properly during updates
- Proper cleanup when navigating between screens