Mark as read button
This commit is contained in:
parent
e8a8bb3b4f
commit
0f563455ff
4 changed files with 21 additions and 4 deletions
|
|
@ -28,7 +28,7 @@ A simple and user-friendly Matrix client made with Flutter and the Matrix Dart S
|
||||||
- [x] Rooms / Spaces
|
- [x] Rooms / Spaces
|
||||||
- [x] Displaying and choosing
|
- [x] Displaying and choosing
|
||||||
- [x] Reading, showing unread
|
- [x] Reading, showing unread
|
||||||
- [ ] Mark as read button on rooms and spaces
|
- [x] Mark as read button on rooms and spaces
|
||||||
- [ ] Searching
|
- [ ] Searching
|
||||||
- [ ] Creating (Rooms, Spaces, and DMs)
|
- [ ] Creating (Rooms, Spaces, and DMs)
|
||||||
- [ ] Joining
|
- [ ] Joining
|
||||||
|
|
|
||||||
|
|
@ -64,7 +64,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: IList(await space.roomData.getAllChildren(client)),
|
children: IList(await space.roomData.getAllChildren()),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
)),
|
)),
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ import "package:nexus/helpers/extensions/get_full_room.dart";
|
||||||
import "package:nexus/models/full_room.dart";
|
import "package:nexus/models/full_room.dart";
|
||||||
|
|
||||||
extension RoomToChildren on Room {
|
extension RoomToChildren on Room {
|
||||||
Future<IList<FullRoom>> getAllChildren(Client client) async {
|
Future<IList<FullRoom>> getAllChildren() async {
|
||||||
final direct = await Future.wait(
|
final direct = await Future.wait(
|
||||||
spaceChildren
|
spaceChildren
|
||||||
.map(
|
.map(
|
||||||
|
|
@ -19,7 +19,7 @@ extension RoomToChildren on Room {
|
||||||
return (await Future.wait(
|
return (await Future.wait(
|
||||||
direct.map(
|
direct.map(
|
||||||
(child) async => child.roomData.isSpace
|
(child) async => child.roomData.isSpace
|
||||||
? await child.roomData.getAllChildren(client)
|
? await child.roomData.getAllChildren()
|
||||||
: [child],
|
: [child],
|
||||||
),
|
),
|
||||||
)).expand((list) => list).toIList();
|
)).expand((list) => list).toIList();
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ import "package:clipboard/clipboard.dart";
|
||||||
import "package:flutter/material.dart";
|
import "package:flutter/material.dart";
|
||||||
import "package:flutter_hooks/flutter_hooks.dart";
|
import "package:flutter_hooks/flutter_hooks.dart";
|
||||||
import "package:matrix/matrix.dart";
|
import "package:matrix/matrix.dart";
|
||||||
|
import "package:nexus/helpers/extensions/room_to_children.dart";
|
||||||
import "package:nexus/widgets/form_text_input.dart";
|
import "package:nexus/widgets/form_text_input.dart";
|
||||||
|
|
||||||
class RoomMenu extends StatelessWidget {
|
class RoomMenu extends StatelessWidget {
|
||||||
|
|
@ -12,6 +13,15 @@ class RoomMenu extends StatelessWidget {
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final danger = Theme.of(context).colorScheme.error;
|
final danger = Theme.of(context).colorScheme.error;
|
||||||
|
|
||||||
|
void markRead(String roomId) async {
|
||||||
|
for (final child in await room.getAllChildren()) {
|
||||||
|
await child.roomData.setReadMarker(
|
||||||
|
child.roomData.lastEvent?.eventId,
|
||||||
|
mRead: child.roomData.lastEvent?.eventId,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return PopupMenuButton(
|
return PopupMenuButton(
|
||||||
itemBuilder: (_) => [
|
itemBuilder: (_) => [
|
||||||
PopupMenuItem(
|
PopupMenuItem(
|
||||||
|
|
@ -21,6 +31,13 @@ class RoomMenu extends StatelessWidget {
|
||||||
},
|
},
|
||||||
child: ListTile(leading: Icon(Icons.link), title: Text("Copy Link")),
|
child: ListTile(leading: Icon(Icons.link), title: Text("Copy Link")),
|
||||||
),
|
),
|
||||||
|
PopupMenuItem(
|
||||||
|
onTap: () => markRead(room.id),
|
||||||
|
child: ListTile(
|
||||||
|
leading: Icon(Icons.check),
|
||||||
|
title: Text("Mark as Read"),
|
||||||
|
),
|
||||||
|
),
|
||||||
PopupMenuItem(
|
PopupMenuItem(
|
||||||
onTap: () => showDialog(
|
onTap: () => showDialog(
|
||||||
context: context,
|
context: context,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue