fix(mobile): include legacy Solo chats in the push lease

Signed-off-by: Tom Brow <tomb@block.xyz>
This commit is contained in:
Tom Brow
2026-10-26 19:10:16 -07:00
parent 63dba6ea76
commit 89585ea93b
2 changed files with 14 additions and 2 deletions

View File

@@ -7,6 +7,7 @@ import '../../features/channels/channel_mutes/channel_mutes_provider.dart';
import '../../features/channels/channels_provider.dart';
import '../community/community.dart';
import '../community/community_provider.dart';
import '../me/me_sync.dart';
import '../relay/relay_provider.dart';
import 'push_subscription.dart';
@@ -24,9 +25,15 @@ final pushSubscriptionSyncProvider = Provider<void>((ref) {
return;
}
// Legacy Solo chats arrive with the encrypted Solo record. Until it loads,
// labelled Solo chats, DMs and mentions still push; the lease updates when
// the record arrives.
final legacySoloChannelIds =
ref.watch(meGroupsProvider).value?.channels ?? const <String>[];
final subscriptions = desiredBuzzPushSubscriptions(
community: active,
channels: channels,
legacySoloChannelIds: legacySoloChannelIds,
mutedChannelIds: [
for (final entry in mutes.store.channels.entries)
if (entry.value.muted) entry.key,
@@ -44,6 +51,7 @@ List<BuzzPushSubscription>? desiredBuzzPushSubscriptions({
required Community community,
required Iterable<Channel> channels,
required Iterable<String> mutedChannelIds,
Iterable<String> legacySoloChannelIds = const [],
}) {
final pubkey = community.pubkey ?? pubkeyFromNsec(community.nsec);
if (pubkey == null || pubkey.isEmpty) return null;
@@ -55,7 +63,8 @@ List<BuzzPushSubscription>? desiredBuzzPushSubscriptions({
// through an exact #p mention, so subscribing to every joined channel
// would over-notify.
for (final channel in channels)
if ((channel.isDm || channel.isPersonalChat(pubkey, const [])) &&
if ((channel.isDm ||
channel.isPersonalChat(pubkey, legacySoloChannelIds)) &&
channel.isMember &&
!channel.isArchived)
channel.id,

View File

@@ -45,6 +45,7 @@ void main() {
const otherSoloID = '123e4567-e89b-42d3-a456-426614174006';
const streamID = '123e4567-e89b-42d3-a456-426614174007';
const mutedSoloID = '123e4567-e89b-42d3-a456-426614174008';
const legacySoloID = '123e4567-e89b-42d3-a456-426614174009';
Channel solo(String id, {String? createdBy, bool archived = false}) =>
channel(
id,
@@ -67,14 +68,16 @@ void main() {
solo(otherSoloID, createdBy: 'author'),
channel(streamID, channelType: 'stream', visibility: 'private'),
solo(mutedSoloID),
channel(legacySoloID, channelType: 'stream', visibility: 'private'),
],
legacySoloChannelIds: const [legacySoloID],
mutedChannelIds: const [mutedSoloID],
);
expect(subscriptions, hasLength(2));
expect(subscriptions!.first.ignore.last.hTags, [mutedSoloID]);
expect(subscriptions.last.filter.kinds, buzzPushChannelKinds);
expect(subscriptions.last.filter.hTags, [dmID, soloID]);
expect(subscriptions.last.filter.hTags, [dmID, soloID, legacySoloID]);
});
test('returns no desired subscriptions without a signing identity', () {