diff --git a/lib/controllers/client_controller.dart b/lib/controllers/client_controller.dart index 8ce4826..1d844fa 100644 --- a/lib/controllers/client_controller.dart +++ b/lib/controllers/client_controller.dart @@ -173,8 +173,8 @@ class ClientController extends AsyncNotifier { Future sendEvent(SendEventRequest request) async => Event.fromJson(await _sendCommand("send_event", request.toJson())); - Future setState(SetStateRequest request) async => - Event.fromJson(await _sendCommand("set_state", request.toJson())); + Future setState(SetStateRequest request) async => + await _sendCommand("set_state", request.toJson()); Future verify(String recoveryKey) async { try { diff --git a/lib/widgets/room_chat.dart b/lib/widgets/room_chat.dart index a5dfc0f..ab294bc 100644 --- a/lib/widgets/room_chat.dart +++ b/lib/widgets/room_chat.dart @@ -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 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(