From 897995667ed97f13bbef6fb2ee0e8f48e0eaabcc Mon Sep 17 00:00:00 2001 From: Henry-Hiles Date: Tue, 14 Jul 2026 16:18:13 -0400 Subject: [PATCH 1/2] better error reporting --- lib/models/requests/set_state_request.dart | 6 ++- lib/widgets/room_chat.dart | 58 +++++++++++----------- 2 files changed, 35 insertions(+), 29 deletions(-) diff --git a/lib/models/requests/set_state_request.dart b/lib/models/requests/set_state_request.dart index f6305c5..6e426af 100644 --- a/lib/models/requests/set_state_request.dart +++ b/lib/models/requests/set_state_request.dart @@ -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 json) => diff --git a/lib/widgets/room_chat.dart b/lib/widgets/room_chat.dart index ab294bc..e8456ac 100644 --- a/lib/widgets/room_chat.dart +++ b/lib/widgets/room_chat.dart @@ -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 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( From 19c94795391901703344cd95aa609f9e91736423 Mon Sep 17 00:00:00 2001 From: Henry-Hiles Date: Tue, 14 Jul 2026 16:20:21 -0400 Subject: [PATCH 2/2] Better error reporting --- lib/models/requests/set_state_request.dart | 6 ++- lib/widgets/room_chat.dart | 58 +++++++++++----------- 2 files changed, 35 insertions(+), 29 deletions(-) diff --git a/lib/models/requests/set_state_request.dart b/lib/models/requests/set_state_request.dart index f6305c5..6e426af 100644 --- a/lib/models/requests/set_state_request.dart +++ b/lib/models/requests/set_state_request.dart @@ -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 json) => diff --git a/lib/widgets/room_chat.dart b/lib/widgets/room_chat.dart index ab294bc..e8456ac 100644 --- a/lib/widgets/room_chat.dart +++ b/lib/widgets/room_chat.dart @@ -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 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(