forked from Henry-Hiles/nexus
Subspace support
This commit is contained in:
parent
67ddc528a4
commit
50c56206db
3 changed files with 29 additions and 12 deletions
|
|
@ -36,7 +36,7 @@ A simple and user-friendly Matrix client made with Flutter and the Matrix Dart S
|
||||||
- [ ] From space
|
- [ ] From space
|
||||||
- [ ] Exploring
|
- [ ] Exploring
|
||||||
- [x] Leaving
|
- [x] Leaving
|
||||||
- [ ] Subspaces
|
- [x] Subspaces
|
||||||
- [x] Messages
|
- [x] Messages
|
||||||
- [x] Sending
|
- [x] Sending
|
||||||
- [x] Plain text
|
- [x] Plain text
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
import "package:collection/collection.dart";
|
|
||||||
import "package:fast_immutable_collections/fast_immutable_collections.dart";
|
import "package:fast_immutable_collections/fast_immutable_collections.dart";
|
||||||
import "package:flutter/material.dart";
|
import "package:flutter/material.dart";
|
||||||
import "package:flutter_riverpod/flutter_riverpod.dart";
|
import "package:flutter_riverpod/flutter_riverpod.dart";
|
||||||
import "package:nexus/controllers/client_controller.dart";
|
import "package:nexus/controllers/client_controller.dart";
|
||||||
import "package:nexus/helpers/extensions/get_full_room.dart";
|
import "package:nexus/helpers/extensions/get_full_room.dart";
|
||||||
|
import "package:nexus/helpers/extensions/room_to_children.dart";
|
||||||
import "package:nexus/models/space.dart";
|
import "package:nexus/models/space.dart";
|
||||||
|
|
||||||
class SpacesController extends AsyncNotifier<IList<Space>> {
|
class SpacesController extends AsyncNotifier<IList<Space>> {
|
||||||
|
|
@ -60,16 +60,7 @@ class SpacesController extends AsyncNotifier<IList<Space>> {
|
||||||
avatar: space.avatar,
|
avatar: space.avatar,
|
||||||
id: space.roomData.id,
|
id: space.roomData.id,
|
||||||
roomData: space.roomData,
|
roomData: space.roomData,
|
||||||
children: await Future.wait(
|
children: await space.roomData.getAllChildren(client),
|
||||||
space.roomData.spaceChildren
|
|
||||||
.map(
|
|
||||||
(child) => client.rooms.firstWhereOrNull(
|
|
||||||
(room) => room.id == child.roomId,
|
|
||||||
),
|
|
||||||
)
|
|
||||||
.nonNulls
|
|
||||||
.map((room) => room.fullRoom),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
)),
|
)),
|
||||||
|
|
|
||||||
26
lib/helpers/extensions/room_to_children.dart
Normal file
26
lib/helpers/extensions/room_to_children.dart
Normal file
|
|
@ -0,0 +1,26 @@
|
||||||
|
import "package:collection/collection.dart";
|
||||||
|
import "package:matrix/matrix.dart";
|
||||||
|
import "package:nexus/helpers/extensions/get_full_room.dart";
|
||||||
|
import "package:nexus/models/full_room.dart";
|
||||||
|
|
||||||
|
extension RoomToChildren on Room {
|
||||||
|
Future<List<FullRoom>> getAllChildren(Client client) async {
|
||||||
|
final direct = await Future.wait(
|
||||||
|
spaceChildren
|
||||||
|
.map(
|
||||||
|
(child) => client.rooms
|
||||||
|
.firstWhereOrNull((r) => r.id == child.roomId)
|
||||||
|
?.fullRoom,
|
||||||
|
)
|
||||||
|
.nonNulls,
|
||||||
|
);
|
||||||
|
|
||||||
|
return (await Future.wait(
|
||||||
|
direct.map(
|
||||||
|
(child) async => child.roomData.isSpace
|
||||||
|
? await child.roomData.getAllChildren(client)
|
||||||
|
: [child],
|
||||||
|
),
|
||||||
|
)).expand((list) => list).toList();
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue