mirror of
https://gitlab.com/famedly/fluffychat.git
synced 2024-11-06 20:19:30 +01:00
fix: Logic which rooms belong to a space
This commit is contained in:
parent
648e690a0d
commit
bb7c095ae3
@ -177,6 +177,28 @@ class ChatListController extends State<ChatList> {
|
|||||||
super.dispose();
|
super.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool roomCheck(Room room) {
|
||||||
|
if (room.isSpace) return false;
|
||||||
|
if (activeSpaceId != null) {
|
||||||
|
final space = Matrix.of(context).client.getRoomById(activeSpaceId);
|
||||||
|
if (space.spaceChildren.any((child) => child.roomId == room.id)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (room.spaceParents.any((parent) => parent.roomId == activeSpaceId)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (room.isDirectChat &&
|
||||||
|
room.summary.mHeroes.any((userId) {
|
||||||
|
final user = space.getState(EventTypes.RoomMember, userId)?.asUser;
|
||||||
|
return user != null && user.membership == Membership.join;
|
||||||
|
})) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
void toggleSelection(String roomId) {
|
void toggleSelection(String roomId) {
|
||||||
setState(() => selectedRoomIds.contains(roomId)
|
setState(() => selectedRoomIds.contains(roomId)
|
||||||
? selectedRoomIds.remove(roomId)
|
? selectedRoomIds.remove(roomId)
|
||||||
|
@ -252,12 +252,8 @@ class _ChatListViewBody extends StatelessWidget {
|
|||||||
builder: (BuildContext context, snapshot) {
|
builder: (BuildContext context, snapshot) {
|
||||||
if (Matrix.of(context).client.prevBatch != null) {
|
if (Matrix.of(context).client.prevBatch != null) {
|
||||||
final rooms = List<Room>.from(Matrix.of(context).client.rooms)
|
final rooms = List<Room>.from(Matrix.of(context).client.rooms)
|
||||||
.where((r) => !r.isSpace)
|
.where(controller.roomCheck)
|
||||||
.toList();
|
.toList();
|
||||||
if (controller.activeSpaceId != null) {
|
|
||||||
rooms.removeWhere((room) => !room.spaceParents.any(
|
|
||||||
(parent) => parent.roomId == controller.activeSpaceId));
|
|
||||||
}
|
|
||||||
rooms.removeWhere((room) => room.lastEvent == null);
|
rooms.removeWhere((room) => room.lastEvent == null);
|
||||||
if (rooms.isEmpty) {
|
if (rooms.isEmpty) {
|
||||||
return Column(
|
return Column(
|
||||||
|
Loading…
Reference in New Issue
Block a user