Skip to content

Commit 81ff7a2

Browse files
committed
refactor(user-management): improve code readability in UserFilterDialogBloc
- Enhance the logic for toggling dashboard role selection - Increase code readability with the addition of comments and restructuring conditional logic - Optimize variable assignment for clarity
1 parent ca35dd9 commit 81ff7a2

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

lib/user_management/widgets/user_filter_dialog/bloc/user_filter_dialog_bloc.dart

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,13 @@ class UserFilterDialogBloc
7171
UserFilterDialogDashboardRoleChanged event,
7272
Emitter<UserFilterDialogState> emit,
7373
) {
74-
if (state.dashboardRole == event.dashboardRole) {
75-
emit(state.copyWith(dashboardRole: null));
76-
} else {
77-
emit(state.copyWith(dashboardRole: event.dashboardRole));
78-
}
74+
// This logic allows toggling the selection. If the user clicks the
75+
// currently selected role, it deselects it (sets to null), which
76+
// corresponds to the 'Any' state.
77+
final newRole = state.dashboardRole == event.dashboardRole
78+
? null
79+
: event.dashboardRole;
80+
emit(state.copyWith(dashboardRole: newRole));
7981
}
8082

8183
/// Resets all temporary filter selections in the dialog.

0 commit comments

Comments
 (0)