add mark as read for rooms/DMs, fixes #24
This commit is contained in:
parent
66ef2de027
commit
469a625c40
2 changed files with 56 additions and 49 deletions
|
|
@ -7,7 +7,7 @@ import "package:nexus/controllers/via_controller.dart";
|
||||||
import "package:nexus/models/room.dart";
|
import "package:nexus/models/room.dart";
|
||||||
|
|
||||||
class RoomMenu extends ConsumerWidget {
|
class RoomMenu extends ConsumerWidget {
|
||||||
final Room room;
|
final Room? room;
|
||||||
final IList<Room> children;
|
final IList<Room> children;
|
||||||
const RoomMenu(this.room, {this.children = const IList.empty(), super.key});
|
const RoomMenu(this.room, {this.children = const IList.empty(), super.key});
|
||||||
|
|
||||||
|
|
@ -20,7 +20,7 @@ class RoomMenu extends ConsumerWidget {
|
||||||
itemBuilder: (_) => [
|
itemBuilder: (_) => [
|
||||||
PopupMenuItem(
|
PopupMenuItem(
|
||||||
onTap: () async {
|
onTap: () async {
|
||||||
await client.markRead(room);
|
if (room != null) await client.markRead(room!);
|
||||||
await Future.wait(children.map((child) => client.markRead(child)));
|
await Future.wait(children.map((child) => client.markRead(child)));
|
||||||
},
|
},
|
||||||
child: ListTile(
|
child: ListTile(
|
||||||
|
|
@ -28,17 +28,22 @@ class RoomMenu extends ConsumerWidget {
|
||||||
title: Text("Mark as Read"),
|
title: Text("Mark as Read"),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
if (room != null) ...[
|
||||||
PopupMenuItem(
|
PopupMenuItem(
|
||||||
onTap: () async {
|
onTap: () async {
|
||||||
final vias = ref.watch(ViaController.provider(room));
|
final vias = ref.watch(ViaController.provider(room!));
|
||||||
|
|
||||||
await Clipboard.setData(
|
await Clipboard.setData(
|
||||||
ClipboardData(
|
ClipboardData(
|
||||||
text: "matrix:roomid/${room.metadata?.id.substring(1)}$vias)",
|
text:
|
||||||
|
"matrix:roomid/${room!.metadata?.id.substring(1)}$vias)",
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
child: ListTile(leading: Icon(Icons.link), title: Text("Copy Link")),
|
child: ListTile(
|
||||||
|
leading: Icon(Icons.link),
|
||||||
|
title: Text("Copy Link"),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
PopupMenuItem(
|
PopupMenuItem(
|
||||||
onTap: () => showDialog(
|
onTap: () => showDialog(
|
||||||
|
|
@ -46,7 +51,7 @@ class RoomMenu extends ConsumerWidget {
|
||||||
builder: (context) => AlertDialog(
|
builder: (context) => AlertDialog(
|
||||||
title: Text("Leave Room"),
|
title: Text("Leave Room"),
|
||||||
content: Text(
|
content: Text(
|
||||||
"Are you sure you want to leave \"${room.metadata?.name ?? "Unnamed Room"}\"?",
|
"Are you sure you want to leave \"${room!.metadata?.name ?? "Unnamed Room"}\"?",
|
||||||
),
|
),
|
||||||
actions: [
|
actions: [
|
||||||
TextButton(
|
TextButton(
|
||||||
|
|
@ -56,13 +61,14 @@ class RoomMenu extends ConsumerWidget {
|
||||||
TextButton(
|
TextButton(
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
Navigator.of(context).pop();
|
Navigator.of(context).pop();
|
||||||
final snackbar = ScaffoldMessenger.of(context).showSnackBar(
|
final snackbar = ScaffoldMessenger.of(context)
|
||||||
|
.showSnackBar(
|
||||||
SnackBar(
|
SnackBar(
|
||||||
content: Text("Leaving room..."),
|
content: Text("Leaving room..."),
|
||||||
duration: Duration(days: 1),
|
duration: Duration(days: 1),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
await client.leaveRoom(room);
|
await client.leaveRoom(room!);
|
||||||
snackbar.close();
|
snackbar.close();
|
||||||
},
|
},
|
||||||
child: Text("Leave"),
|
child: Text("Leave"),
|
||||||
|
|
@ -75,6 +81,8 @@ class RoomMenu extends ConsumerWidget {
|
||||||
title: Text("Leave", style: TextStyle(color: danger)),
|
title: Text("Leave", style: TextStyle(color: danger)),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
],
|
||||||
|
|
||||||
// PopupMenuItem(
|
// PopupMenuItem(
|
||||||
// onTap: () => showDialog(
|
// onTap: () => showDialog(
|
||||||
// context: context,
|
// context: context,
|
||||||
|
|
|
||||||
|
|
@ -140,9 +140,8 @@ class Sidebar extends HookConsumerWidget {
|
||||||
),
|
),
|
||||||
backgroundColor: Colors.transparent,
|
backgroundColor: Colors.transparent,
|
||||||
actions: [
|
actions: [
|
||||||
if (selectedSpace.room != null)
|
|
||||||
RoomMenu(
|
RoomMenu(
|
||||||
selectedSpace.room!,
|
selectedSpace.room,
|
||||||
children: selectedSpace.children,
|
children: selectedSpace.children,
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue