App pack event filtering fix

This commit is contained in:
franzap
2025-12-16 13:53:10 -03:00
parent b41189dc10
commit ca30f6049d
3 changed files with 37 additions and 21 deletions
+27
View File
@@ -12,6 +12,33 @@ const kFranzapPubkey =
/// Identifier for storing user bookmarks
const kAppBookmarksIdentifier = 'zapstore-bookmarks';
/// Event filter for app packs - excludes bookmarks and packs with zero App references
bool appPackEventFilter(Map<String, dynamic> event) {
final tags = event['tags'] as List<dynamic>?;
if (tags == null) return false;
// Check for bookmarks identifier in 'd' tag
for (final tag in tags) {
if (tag is List && tag.isNotEmpty && tag[0] == 'd') {
if (tag.length > 1 && tag[1] == kAppBookmarksIdentifier) {
return false;
}
}
}
// Check for at least one 'a' tag starting with '32267:' (App kind)
for (final tag in tags) {
if (tag is List && tag.isNotEmpty && tag[0] == 'a') {
if (tag.length > 1 && tag[1] is String && tag[1].startsWith('32267:')) {
return true;
}
}
}
// No valid App references found
return false;
}
/// Amber signer package ID
const kAmberPackageId = 'com.greenart7c3.nostrsigner';
+7 -11
View File
@@ -60,7 +60,11 @@ class UserScreen extends HookConsumerWidget {
authors: {pubkey},
limit: 20,
and: (pack) => {pack.apps},
source: const LocalAndRemoteSource(stream: false, relays: 'social'),
source: LocalAndRemoteSource(
stream: false,
relays: 'social',
eventFilter: appPackEventFilter,
),
andSource: const LocalAndRemoteSource(
relays: 'AppCatalog',
stream: false,
@@ -68,16 +72,8 @@ class UserScreen extends HookConsumerWidget {
subscriptionPrefix: 'user-packs',
),
);
final packs =
appPacksState.models
.where((p) => p.identifier != kAppBookmarksIdentifier)
.where(
(p) => p.apps.toList().any(
(a) => a.name != null || a.identifier.isNotEmpty,
),
)
.toList()
..sort((a, b) => b.event.createdAt.compareTo(a.event.createdAt));
final packs = appPacksState.models
..sort((a, b) => b.event.createdAt.compareTo(a.event.createdAt));
return Scaffold(
body: SafeArea(
+3 -10
View File
@@ -27,9 +27,10 @@ class AppPackContainer extends HookConsumerWidget {
query<AppPack>(
limit: 20,
and: (pack) => {pack.apps},
source: const LocalAndRemoteSource(
source: LocalAndRemoteSource(
stream: true,
relays: 'social',
eventFilter: appPackEventFilter,
),
andSource: const LocalAndRemoteSource(
relays: 'AppCatalog',
@@ -41,15 +42,7 @@ class AppPackContainer extends HookConsumerWidget {
final packs = switch (appPacksState) {
StorageData(:final models) =>
models
.where((p) => p.identifier != kAppBookmarksIdentifier)
.where(
(p) => p.apps.toList().any(
(a) => a.name != null || a.identifier.isNotEmpty,
),
)
.toList()
..sort((a, b) => b.event.createdAt.compareTo(a.event.createdAt)),
models..sort((a, b) => b.event.createdAt.compareTo(a.event.createdAt)),
_ => <AppPack>[],
};