Skip to content

Commit

Permalink
Fix filtering of single rooms on home screen (#303)
Browse files Browse the repository at this point in the history
  • Loading branch information
Airyzz authored Jul 2, 2024
1 parent 4b6920d commit d89fea2
Showing 1 changed file with 23 additions and 4 deletions.
27 changes: 23 additions & 4 deletions commet/lib/client/client_manager.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import 'dart:async';
import 'package:commet/client/alert.dart';
import 'package:commet/client/client.dart';
import 'package:commet/client/components/direct_messages/direct_message_aggregator.dart';
import 'package:commet/client/components/direct_messages/direct_message_component.dart';
import 'package:commet/client/matrix/matrix_client.dart';
import 'package:commet/client/stale_info.dart';
import 'package:commet/client/tasks/client_connection_status_task.dart';
Expand All @@ -26,10 +27,28 @@ class ClientManager {

List<Room> get rooms => _rooms;

List<Room> get singleRooms => rooms
.where(
(room) => !spaces.any((space) => space.containsRoom(room.identifier)))
.toList();
List<Room> get singleRooms {
var result = List<Room>.empty(growable: true);
for (var client in clients) {
var dmComp = client.getComponent<DirectMessagesComponent>();

for (var room in client.rooms) {
if (dmComp != null) {
if (dmComp.isRoomDirectMessage(room)) {
continue;
}
}

if (client.spaces.any((space) => space.containsRoom(room.identifier))) {
continue;
}

result.add(room);
}
}

return result;
}

List<Space> get spaces => _spaces;

Expand Down

0 comments on commit d89fea2

Please sign in to comment.