Watch
1
0
Fork
You've already forked nexus
0
forked from Nexus/nexus

Show space hierarchies

Fixes #83
This commit is contained in:
Henry Hiles 2026-10-15 22:34:27 -04:00
commit b71a7f0bd6
Signed by: Henry-Hiles
SSH key fingerprint: SHA256:VKQUdS31Q90KvX7EkKMHMBpUspcmItAh86a+v7PGiIs
10 changed files with 519 additions and 98 deletions

View file

@ -0,0 +1,34 @@
import "package:hooks_riverpod/hooks_riverpod.dart";
import "package:nexus/controllers/client.dart";
import "package:nexus/models/space_hierarchy.dart";
class SpaceHierarchyController(final String spaceId)
extends AsyncNotifier<SpaceHierarchy> {
@override
Future<SpaceHierarchy> build() => ref
.read(ClientController.provider.notifier)
.getSpaceHierarchy(.new(roomId: spaceId, maxDepth: 1));
Future<void> loadMore() async {
final current = await future;
if (current.nextBatch == null) return;
final next = await ref
.read(ClientController.provider.notifier)
.getSpaceHierarchy(
.new(roomId: spaceId, maxDepth: 1, from: current.nextBatch),
);
state = AsyncData(
current.copyWith(
rooms: current.rooms.addAll(next.rooms),
nextBatch: next.nextBatch,
),
);
}
static final provider = AsyncNotifierProvider.family
.autoDispose<SpaceHierarchyController, SpaceHierarchy, String>(
SpaceHierarchyController.new,
);
}