make PinnedEventsController expose IList of eventRowIds
This commit is contained in:
parent
a91b45be31
commit
2e85b26511
2 changed files with 7 additions and 8 deletions
|
|
@ -2,26 +2,25 @@ import "package:fast_immutable_collections/fast_immutable_collections.dart";
|
|||
import "package:hooks_riverpod/hooks_riverpod.dart";
|
||||
import "package:nexus/controllers/event.dart";
|
||||
import "package:nexus/controllers/pinned_ids.dart";
|
||||
import "package:nexus/models/event.dart";
|
||||
|
||||
class PinnedEventsController(final String roomId)
|
||||
extends AsyncNotifier<IList<Event>> {
|
||||
extends AsyncNotifier<IList<int>> {
|
||||
@override
|
||||
Future<IList<Event>> build() async {
|
||||
Future<IList<int>> build() async {
|
||||
final pinIds = ref.watch(PinnedIdsController.provider(roomId));
|
||||
|
||||
return (await Future.wait(
|
||||
pinIds.map(
|
||||
(eventId) => ref.watch(
|
||||
EventController.provider(.new(eventId: eventId, roomId: roomId))
|
||||
.future,
|
||||
.selectAsync((data) => data?.rowId),
|
||||
),
|
||||
),
|
||||
)).nonNulls.toIList();
|
||||
}
|
||||
|
||||
static final provider = AsyncNotifierProvider.family
|
||||
.autoDispose<PinnedEventsController, IList<Event>, String>(
|
||||
.autoDispose<PinnedEventsController, IList<int>, String>(
|
||||
PinnedEventsController.new,
|
||||
);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue