better error reporting
This commit is contained in:
parent
fbc6f88afb
commit
897995667e
2 changed files with 32 additions and 26 deletions
|
|
@ -11,7 +11,11 @@ abstract class SetStateRequest with _$SetStateRequest {
|
|||
required String type,
|
||||
required String stateKey,
|
||||
required Content content,
|
||||
@JsonKey(name: "delay_ms") @MSDuration() @Default(null) Duration? delay,
|
||||
|
||||
@JsonKey(name: "delay_ms", includeIfNull: false)
|
||||
@MSDuration()
|
||||
@Default(null)
|
||||
Duration? delay,
|
||||
}) = _SetStateRequest;
|
||||
|
||||
factory SetStateRequest.fromJson(Map<String, Object?> json) =>
|
||||
|
|
|
|||
|
|
@ -175,36 +175,17 @@ 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;
|
||||
|
||||
final isPinned = ref
|
||||
.watch(PinnedEventsController.provider(roomId))
|
||||
.whenOrNull(
|
||||
data: (pinnedEvents) =>
|
||||
pinnedEvents.any((ev) => ev.eventId == event.eventId),
|
||||
);
|
||||
|
||||
return [
|
||||
if (ref.watch(
|
||||
PowerLevelController.provider(
|
||||
|
|
@ -282,7 +263,28 @@ class RoomChat extends HookConsumerWidget {
|
|||
PowerLevelConfig(eventType: .pinnedEvents, roomId: roomId),
|
||||
),
|
||||
))
|
||||
buildPinOption(event),
|
||||
PopupMenuItem(
|
||||
onTap: isPinned == null
|
||||
? null
|
||||
: () async {
|
||||
try {
|
||||
final notifier = ref.read(
|
||||
PinnedEventsController.provider(roomId).notifier,
|
||||
);
|
||||
if (isPinned) {
|
||||
await notifier.removePin(event);
|
||||
} else {
|
||||
await notifier.addPin(event);
|
||||
}
|
||||
} catch (error, stackTrace) {
|
||||
showError(error, stackTrace);
|
||||
}
|
||||
},
|
||||
child: ListTile(
|
||||
leading: Icon(Icons.push_pin),
|
||||
title: Text(isPinned == true ? "Unpin Event" : "Pin Event"),
|
||||
),
|
||||
),
|
||||
PopupMenuItem(
|
||||
onTap: () async {
|
||||
final room = ref.watch(
|
||||
|
|
|
|||
Loading…
Reference in a new issue