slightly improve bitfield handling for UnreadType

This commit is contained in:
Henry Hiles 2026-10-05 20:16:01 -04:00
commit c81000d6c6
Signed by: Henry-Hiles
SSH key fingerprint: SHA256:VKQUdS31Q90KvX7EkKMHMBpUspcmItAh86a+v7PGiIs
2 changed files with 3 additions and 6 deletions

View file

@ -87,7 +87,7 @@ class UnifiedPushController extends AsyncNotifier<bool> {
final (event, roomMetadata) = pushResponse; final (event, roomMetadata) = pushResponse;
if (event.unreadType?.shouldNotify() != true || if (event.unreadType?.has(.notify) != true ||
(!isInBackground && (!isInBackground &&
await windowManager.isFocused().onError((_, _) => true) && await windowManager.isFocused().onError((_, _) => true) &&
await ref.read( await ref.read(

View file

@ -102,9 +102,6 @@ class const UnreadType(final int value) with _$UnreadType {
static const highlight = UnreadType(4); static const highlight = UnreadType(4);
static const sound = UnreadType(8); static const sound = UnreadType(8);
bool isNone() => value == 0; bool has(UnreadType flag) => value & flag.value != 0;
bool isNormal() => (value & 1) != 0; UnreadType operator |(UnreadType other) => UnreadType(value | other.value);
bool shouldNotify() => (value & 2) != 0;
bool isHighlighted() => (value & 4) != 0;
bool playsSound() => (value & 8) != 0;
} }