refactor(mobile): Use switch expression when possible (#15852)

refactor: Use `switch` expression when possible

Co-authored-by: Alex <alex.tran1502@gmail.com>
This commit is contained in:
Damiano Ferrari
2025-02-02 22:46:46 +01:00
committed by GitHub
parent 4efacfbb91
commit 96a6cc20b7
17 changed files with 219 additions and 374 deletions
+4 -7
View File
@@ -25,13 +25,10 @@ class UserRepository extends DatabaseRepository implements IUserRepository {
final int userId = Store.get(StoreKey.currentUser).isarId;
final QueryBuilder<User, User, QAfterWhereClause> afterWhere =
self ? baseQuery.noOp() : baseQuery.isarIdNotEqualTo(userId);
final QueryBuilder<User, User, QAfterSortBy> query;
switch (sortBy) {
case null:
query = afterWhere.noOp();
case UserSort.id:
query = afterWhere.sortById();
}
final QueryBuilder<User, User, QAfterSortBy> query = switch (sortBy) {
null => afterWhere.noOp(),
UserSort.id => afterWhere.sortById(),
};
return query.findAll();
}