From c81000d6c6dfd79068dadaf0f0281f096460367d Mon Sep 17 00:00:00 2001 From: Henry-Hiles Date: Mon, 5 Oct 2026 20:16:01 -0400 Subject: [PATCH] slightly improve bitfield handling for UnreadType --- lib/controllers/unified_push.dart | 2 +- lib/models/event.dart | 7 ++----- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/lib/controllers/unified_push.dart b/lib/controllers/unified_push.dart index 8e24d16..97849fe 100644 --- a/lib/controllers/unified_push.dart +++ b/lib/controllers/unified_push.dart @@ -87,7 +87,7 @@ class UnifiedPushController extends AsyncNotifier { final (event, roomMetadata) = pushResponse; - if (event.unreadType?.shouldNotify() != true || + if (event.unreadType?.has(.notify) != true || (!isInBackground && await windowManager.isFocused().onError((_, _) => true) && await ref.read( diff --git a/lib/models/event.dart b/lib/models/event.dart index dc3dd46..de065fe 100644 --- a/lib/models/event.dart +++ b/lib/models/event.dart @@ -102,9 +102,6 @@ class const UnreadType(final int value) with _$UnreadType { static const highlight = UnreadType(4); static const sound = UnreadType(8); - bool isNone() => value == 0; - bool isNormal() => (value & 1) != 0; - bool shouldNotify() => (value & 2) != 0; - bool isHighlighted() => (value & 4) != 0; - bool playsSound() => (value & 8) != 0; + bool has(UnreadType flag) => value & flag.value != 0; + UnreadType operator |(UnreadType other) => UnreadType(value | other.value); }