mirror of
https://github.com/zapstore/zapstore.git
synced 2026-10-05 20:48:24 +00:00
App pack event filtering fix
This commit is contained in:
@@ -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';
|
||||
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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>[],
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user