Skip to content

Commit 6f18805

Browse files
browclaude
andcommitted
fix(mobile): treat muted Solo chats like muted channels in the push lease
Muted Solo chats stay out of the lease, as muted channels always have, so they push only on mention. This removes the separate muted budget, past which some muted Solo chats were silent and others notified on mention. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Tom Brow <[email protected]>
1 parent 4dfef54 commit 6f18805

2 files changed

Lines changed: 15 additions & 32 deletions

File tree

‎mobile/lib/shared/push/push_subscription_provider.dart‎

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -139,22 +139,18 @@ desiredBuzzPushSubscriptions({
139139
for (final channel in joined)
140140
if (channel.isDm) channel.id,
141141
];
142+
// Muted Solo chats stay out, like muted channels, so they push only on
143+
// mention.
142144
final ordered = [
143145
for (final channel in joined)
144-
if (!channel.isDm && channel.isPersonalChat(pubkey, legacySoloChannelIds))
146+
if (!channel.isDm &&
147+
!isMuted(channel.id) &&
148+
channel.isPersonalChat(pubkey, legacySoloChannelIds))
145149
channel,
146150
]..sort(_mostRecentFirst);
147-
148-
var unmutedRoom =
151+
final room =
149152
buzzPushMaxChannelWideChannels - dms.where((id) => !isMuted(id)).length;
150-
var mutedRoom = buzzPushMaxMutedChannels - dms.where(isMuted).length;
151-
final solos = <String>[];
152-
for (final solo in ordered) {
153-
final soloMuted = isMuted(solo.id);
154-
if ((soloMuted ? mutedRoom : unmutedRoom) <= 0) continue;
155-
solos.add(solo.id);
156-
soloMuted ? mutedRoom-- : unmutedRoom--;
157-
}
153+
final solos = [for (final solo in ordered.take(room < 0 ? 0 : room)) solo.id];
158154
return (dms: dms, solos: solos, omitted: ordered.length - solos.length);
159155
}
160156

‎mobile/test/shared/push/push_subscription_provider_test.dart‎

Lines changed: 8 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,10 @@ void main() {
8787
mutedChannelIds: const [mutedSoloID],
8888
)?.subscriptions;
8989

90+
// A muted Solo chat is left out, like a muted channel, so only a
91+
// mention pushes it.
9092
expect(subscriptions, hasLength(2));
91-
expect(subscriptions!.first.ignore.last.hTags, [mutedSoloID]);
93+
expect(subscriptions!.first.ignore, hasLength(1));
9294
expect(subscriptions.last.filter.kinds, buzzPushChannelKinds);
9395
expect(subscriptions.last.filter.hTags, [dmID, soloID, legacySoloID]);
9496
});
@@ -132,21 +134,14 @@ void main() {
132134
);
133135
});
134136

135-
for (final (limit, descriptor, soloCount, mutedSolos) in [
137+
for (final (limit, descriptor, soloCount) in [
136138
(
137139
'plaintext',
138-
_descriptor(contentLength: 65536, plaintextLength: 32768),
140+
_descriptor(contentLength: 65536, plaintextLength: 16384),
139141
400,
140-
100,
141142
),
142-
(
143-
'content',
144-
_descriptor(contentLength: 24000, plaintextLength: 32768),
145-
400,
146-
100,
147-
),
148-
('muted channel count', _descriptor(), 400, 400),
149-
('NIP-44 plaintext', _descriptor(), 600, 200),
143+
('content', _descriptor(contentLength: 24000, plaintextLength: 32768), 400),
144+
('NIP-44 plaintext', _descriptor(endpointLength: 40000), 700),
150145
]) {
151146
test('keeps the newest Solo chats within the $limit limit', () async {
152147
final keys = nostr.Keys.generate();
@@ -156,24 +151,16 @@ void main() {
156151
for (var n = dmCount; n < dmCount + soloCount; n++)
157152
_solo(n, keys.public),
158153
];
159-
// Muted chats are the newest, so every lease filter ignores them.
160-
final muted = [
161-
for (var n = channels.length - mutedSolos; n < channels.length; n++)
162-
_id(n),
163-
];
164-
165154
final desired = desiredBuzzPushSubscriptions(
166155
community: _community(keys),
167156
descriptor: descriptor,
168157
channels: channels,
169-
mutedChannelIds: muted,
158+
mutedChannelIds: const [],
170159
)!;
171160

172161
final kept = {
173162
for (final subscription in desired.subscriptions.skip(1))
174163
...?subscription.filter.hTags,
175-
for (final ignore in desired.subscriptions.first.ignore.skip(1))
176-
...?ignore.hTags,
177164
};
178165
final keptSolos = soloCount - desired.omittedSoloChats;
179166
expect(keptSolos, inInclusiveRange(1, soloCount - 1));

0 commit comments

Comments
 (0)