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:
parent
135be17555
commit
82f72f99c0
2 changed files with 30 additions and 30 deletions
|
|
@ -173,8 +173,8 @@ class ClientController extends AsyncNotifier<int> {
|
||||||
Future<Event> sendEvent(SendEventRequest request) async =>
|
Future<Event> sendEvent(SendEventRequest request) async =>
|
||||||
Event.fromJson(await _sendCommand("send_event", request.toJson()));
|
Event.fromJson(await _sendCommand("send_event", request.toJson()));
|
||||||
|
|
||||||
Future<Event> setState(SetStateRequest request) async =>
|
Future<String?> setState(SetStateRequest request) async =>
|
||||||
Event.fromJson(await _sendCommand("set_state", request.toJson()));
|
await _sendCommand("set_state", request.toJson());
|
||||||
|
|
||||||
Future<String?> verify(String recoveryKey) async {
|
Future<String?> verify(String recoveryKey) async {
|
||||||
try {
|
try {
|
||||||
|
|
|
||||||
|
|
@ -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) {
|
IList<PopupMenuEntry> getEventOptions(Event event) {
|
||||||
final danger = theme.colorScheme.error;
|
final danger = theme.colorScheme.error;
|
||||||
final isSentByMe = event.sender == userId;
|
final isSentByMe = event.sender == userId;
|
||||||
|
|
@ -255,34 +282,7 @@ class RoomChat extends HookConsumerWidget {
|
||||||
PowerLevelConfig(eventType: .pinnedEvents, roomId: roomId),
|
PowerLevelConfig(eventType: .pinnedEvents, roomId: roomId),
|
||||||
),
|
),
|
||||||
))
|
))
|
||||||
() {
|
buildPinOption(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"),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}(),
|
|
||||||
PopupMenuItem(
|
PopupMenuItem(
|
||||||
onTap: () async {
|
onTap: () async {
|
||||||
final room = ref.watch(
|
final room = ref.watch(
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue