forked from Henry-Hiles/nexus
fix some stuff (maybe?)
This commit is contained in:
parent
a4d60e6c83
commit
3e82faeb86
10 changed files with 58 additions and 36 deletions
|
|
@ -9,7 +9,9 @@ class MessageController extends AsyncNotifier<TextMessage?> {
|
|||
|
||||
@override
|
||||
Future<TextMessage?> build() async {
|
||||
final room = await ref.watch(SelectedRoomController.provider.future);
|
||||
final room = await ref.watch(
|
||||
SelectedRoomController.provider.selectAsync((a) => a),
|
||||
);
|
||||
if (room == null) return null;
|
||||
|
||||
final event = await room.roomData.getEventById(id);
|
||||
|
|
|
|||
|
|
@ -82,8 +82,10 @@ class RoomChatController extends AsyncNotifier<ChatController> {
|
|||
}
|
||||
|
||||
Future<void> markRead() async {
|
||||
if (!room.hasNewMessages) return;
|
||||
final controller = await future;
|
||||
final id = controller.messages.last.id;
|
||||
|
||||
await room.setReadMarker(id, mRead: id);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -5,14 +5,6 @@ import "package:nexus/controllers/selected_space_controller.dart";
|
|||
import "package:nexus/models/full_room.dart";
|
||||
|
||||
class SelectedRoomController extends AsyncNotifier<FullRoom?> {
|
||||
@override
|
||||
bool updateShouldNotify(
|
||||
AsyncValue<FullRoom?> previous,
|
||||
AsyncValue<FullRoom?> next,
|
||||
) =>
|
||||
previous.value?.avatar != next.value?.avatar ||
|
||||
previous.value?.title != next.value?.title;
|
||||
|
||||
@override
|
||||
Future<FullRoom?> build() async {
|
||||
final space = await ref.watch(SelectedSpaceController.provider.future);
|
||||
|
|
|
|||
|
|
@ -15,23 +15,25 @@ class SpacesController extends AsyncNotifier<IList<Space>> {
|
|||
client.onSync.stream.listen((_) => ref.invalidateSelf()).cancel,
|
||||
);
|
||||
|
||||
final topLevel = await Future.wait(
|
||||
client.rooms
|
||||
.where((room) => !room.isDirectChat)
|
||||
.where(
|
||||
(room) => client.rooms
|
||||
.where((room) => room.isSpace)
|
||||
.every(
|
||||
(match) => match.spaceChildren.every(
|
||||
(child) => child.roomId != room.id,
|
||||
final topLevel = IList(
|
||||
await Future.wait(
|
||||
client.rooms
|
||||
.where((room) => !room.isDirectChat)
|
||||
.where(
|
||||
(room) => client.rooms
|
||||
.where((room) => room.isSpace)
|
||||
.every(
|
||||
(match) => match.spaceChildren.every(
|
||||
(child) => child.roomId != room.id,
|
||||
),
|
||||
),
|
||||
),
|
||||
)
|
||||
.map((room) => room.fullRoom),
|
||||
)
|
||||
.map((room) => room.fullRoom),
|
||||
),
|
||||
);
|
||||
|
||||
final topLevelSpaces = topLevel.where((r) => r.roomData.isSpace).toList();
|
||||
final topLevelRooms = topLevel.where((r) => !r.roomData.isSpace).toList();
|
||||
final topLevelSpaces = topLevel.where((r) => r.roomData.isSpace).toIList();
|
||||
final topLevelRooms = topLevel.where((r) => !r.roomData.isSpace).toIList();
|
||||
|
||||
return IList([
|
||||
Space(
|
||||
|
|
@ -45,10 +47,12 @@ class SpacesController extends AsyncNotifier<IList<Space>> {
|
|||
client: client,
|
||||
title: "Direct Messages",
|
||||
id: "dms",
|
||||
children: await Future.wait(
|
||||
client.rooms
|
||||
.where((room) => room.isDirectChat)
|
||||
.map((room) => room.fullRoom),
|
||||
children: IList(
|
||||
await Future.wait(
|
||||
client.rooms
|
||||
.where((room) => room.isDirectChat)
|
||||
.map((room) => room.fullRoom),
|
||||
),
|
||||
),
|
||||
icon: Icon(Icons.person),
|
||||
),
|
||||
|
|
@ -60,7 +64,7 @@ class SpacesController extends AsyncNotifier<IList<Space>> {
|
|||
avatar: space.avatar,
|
||||
id: space.roomData.id,
|
||||
roomData: space.roomData,
|
||||
children: await space.roomData.getAllChildren(client),
|
||||
children: IList(await space.roomData.getAllChildren(client)),
|
||||
),
|
||||
),
|
||||
)),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue