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

Corrected return type for SetState from JSON to String & replaced IIFE in room_chat with default builder function call.

This commit is contained in:
istalri 2026-07-12 01:37:39 +02:00
commit 82f72f99c0
2 changed files with 30 additions and 30 deletions

View file

@ -173,8 +173,8 @@ class ClientController extends AsyncNotifier<int> {
Future<Event> sendEvent(SendEventRequest request) async =>
Event.fromJson(await _sendCommand("send_event", request.toJson()));
Future<Event> setState(SetStateRequest request) async =>
Event.fromJson(await _sendCommand("set_state", request.toJson()));
Future<String?> setState(SetStateRequest request) async =>
await _sendCommand("set_state", request.toJson());
Future<String?> verify(String recoveryKey) async {
try {

View file

@ -175,6 +175,33 @@ class RoomChat extends HookConsumerWidget {
},
);
PopupMenuItem buildPinOption(Event event) {
final isPinned = ref
.watch(PinnedEventsController.provider(roomId))
.maybeWhen(
data: (pinnedEvents) =>
pinnedEvents.any((ev) => ev.eventId == event.eventId),
orElse: () => false,
);
return PopupMenuItem(
onTap: () async {
final notifier = ref.read(
PinnedEventsController.provider(roomId).notifier,
);
if (isPinned) {
await notifier.removePin(event);
} else {
await notifier.addPin(event);
}
},
child: ListTile(
leading: Icon(isPinned ? Icons.push_pin_outlined : Icons.push_pin),
title: Text(isPinned ? "Unpin Event" : "Pin Event"),
),
);
}
IList<PopupMenuEntry> getEventOptions(Event event) {
final danger = theme.colorScheme.error;
final isSentByMe = event.sender == userId;
@ -255,34 +282,7 @@ class RoomChat extends HookConsumerWidget {
PowerLevelConfig(eventType: .pinnedEvents, roomId: roomId),
),
))
() {
final isPinned = ref
.watch(PinnedEventsController.provider(roomId))
.maybeWhen(
data: (pinnedEvents) =>
pinnedEvents.any((ev) => ev.eventId == event.eventId),
orElse: () => false,
);
return PopupMenuItem(
onTap: () async {
final notifier = ref.read(
PinnedEventsController.provider(roomId).notifier,
);
if (isPinned) {
await notifier.removePin(event);
} else {
await notifier.addPin(event);
}
},
child: ListTile(
leading: Icon(
isPinned ? Icons.push_pin_outlined : Icons.push_pin,
),
title: Text(isPinned ? "Unpin Event" : "Pin Event"),
),
);
}(),
buildPinOption(event),
PopupMenuItem(
onTap: () async {
final room = ref.watch(