mirror of
https://github.com/zapstore/zapstore.git
synced 2026-10-05 20:48:24 +00:00
Improve curation set feature, fix provider
This commit is contained in:
@@ -158,5 +158,5 @@ mixin UserAdapter on NostrAdapter<User> {
|
||||
const kZapstorePubkey =
|
||||
'78ce6faa72264387284e647ba6938995735ec8c7d5c5a65737e55130f026307d';
|
||||
|
||||
const kFranzapNpub =
|
||||
'npub1wf4pufsucer5va8g9p0rj5dnhvfeh6d8w0g6eayaep5dhps6rsgs43dgh9';
|
||||
const kFranzapPubkey =
|
||||
'726a1e261cc6474674e8285e3951b3bb139be9a773d1acf49dc868db861a1c11';
|
||||
|
||||
@@ -40,7 +40,7 @@ final appInitializer = FutureProvider<void>((ref) async {
|
||||
}
|
||||
|
||||
// Preload zapstore's nostr curation set
|
||||
ref.read(appCurationSetProvider(kNostrCurationSet).notifier).fetch();
|
||||
ref.read(appCurationSetProvider(kNostrCurationSetLink).notifier).fetch();
|
||||
|
||||
// App-wide listeners
|
||||
|
||||
|
||||
@@ -131,8 +131,7 @@ class AppDetailScreen extends HookConsumerWidget {
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(10),
|
||||
child: UsersRichText(
|
||||
trailingText:
|
||||
' recommend${curatedBy.length == 1 ? 's' : ''} this app',
|
||||
trailingText: ' picked this app',
|
||||
users: curatedBy.toList(),
|
||||
),
|
||||
),
|
||||
|
||||
@@ -5,7 +5,6 @@ import 'package:gap/gap.dart';
|
||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||
import 'package:purplebase/purplebase.dart';
|
||||
import 'package:zapstore/main.data.dart';
|
||||
import 'package:zapstore/models/app.dart';
|
||||
import 'package:zapstore/models/app_curation_set.dart';
|
||||
import 'package:zapstore/models/user.dart';
|
||||
import 'package:zapstore/widgets/horizontal_grid.dart';
|
||||
@@ -24,11 +23,11 @@ class AppCurationContainer extends HookConsumerWidget {
|
||||
|
||||
// Custom curation set to place nostr set first (as its preloaded)
|
||||
final nostrCurationSet = appCurationSets.firstWhereOrNull(
|
||||
(s) => s.getReplaceableEventLink() == kNostrCurationSet);
|
||||
final customAppCurationSets = [
|
||||
if (nostrCurationSet != null) nostrCurationSet,
|
||||
...appCurationSets..remove(nostrCurationSet)
|
||||
];
|
||||
(s) => s.getReplaceableEventLink() == kNostrCurationSetLink);
|
||||
if (nostrCurationSet != null) {
|
||||
appCurationSets.remove(nostrCurationSet);
|
||||
appCurationSets.insert(0, nostrCurationSet);
|
||||
}
|
||||
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
@@ -38,7 +37,7 @@ class AppCurationContainer extends HookConsumerWidget {
|
||||
controller: scrollController,
|
||||
child: Row(
|
||||
children: [
|
||||
for (final appCurationSet in customAppCurationSets)
|
||||
for (final appCurationSet in appCurationSets)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(right: 12),
|
||||
child: GestureDetector(
|
||||
@@ -109,27 +108,19 @@ class AppCurationSetNotifier
|
||||
|
||||
Future<void> fetch() async {
|
||||
final appCurationSet = await future;
|
||||
final appsLocal =
|
||||
ref.apps.appAdapter.findWhereIdentifierInLocal(appCurationSet.appIds);
|
||||
// TODO: Rethink this logic (checking on empty)
|
||||
if (appsLocal.isEmpty) {
|
||||
state = AsyncLoading();
|
||||
state = await AsyncValue.guard(() async {
|
||||
// Only load apps (no releases for now)
|
||||
// We can use ignoreReturn here as we do not care about releases
|
||||
await ref.apps.findAll(
|
||||
params: {
|
||||
'#d': appCurationSet.appIds,
|
||||
'includes': false,
|
||||
'ignoreReturn': true,
|
||||
},
|
||||
);
|
||||
// Since the set is the same as before (the relationship changed),
|
||||
// manually invalidate the provider
|
||||
ref.invalidateSelf();
|
||||
return appCurationSet;
|
||||
});
|
||||
}
|
||||
state = AsyncLoading();
|
||||
state = await AsyncValue.guard(() async {
|
||||
// Only load apps (no releases for now)
|
||||
// We can use ignoreReturn here as we do not care about releases
|
||||
await ref.apps.findAll(
|
||||
params: {
|
||||
'#d': appCurationSet.appIds,
|
||||
'includes': false,
|
||||
'ignoreReturn': true,
|
||||
},
|
||||
);
|
||||
return appCurationSet;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -139,6 +130,6 @@ final appCurationSetProvider = AsyncNotifierProvider.family<
|
||||
ReplaceableEventLink>(AppCurationSetNotifier.new);
|
||||
|
||||
final _selectedIdProvider =
|
||||
StateProvider<ReplaceableEventLink>((_) => kNostrCurationSet);
|
||||
StateProvider<ReplaceableEventLink>((_) => kNostrCurationSetLink);
|
||||
|
||||
const kNostrCurationSet = (30267, kZapstorePubkey, 'nostr');
|
||||
const kNostrCurationSetLink = (30267, kFranzapPubkey, 'nostr');
|
||||
|
||||
@@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter_hooks/flutter_hooks.dart';
|
||||
import 'package:gap/gap.dart';
|
||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||
import 'package:purplebase/purplebase.dart';
|
||||
import 'package:zapstore/main.data.dart';
|
||||
import 'package:zapstore/models/app.dart';
|
||||
import 'package:zapstore/models/settings.dart';
|
||||
@@ -49,7 +50,7 @@ class InstallAlertDialog extends HookConsumerWidget {
|
||||
Gap(20),
|
||||
if (app.signer.value != null)
|
||||
WebOfTrustContainer(
|
||||
fromNpub: user?.npub ?? kFranzapNpub,
|
||||
fromNpub: user?.npub ?? kFranzapPubkey.npub,
|
||||
toNpub: app.signer.value!.npub,
|
||||
),
|
||||
if (user == null)
|
||||
|
||||
@@ -2,6 +2,7 @@ import 'package:collection/collection.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:gap/gap.dart';
|
||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||
import 'package:purplebase/purplebase.dart';
|
||||
import 'package:zapstore/main.data.dart';
|
||||
import 'package:zapstore/models/settings.dart';
|
||||
import 'package:zapstore/models/user.dart';
|
||||
@@ -36,7 +37,7 @@ class WebOfTrustContainer extends HookConsumerWidget {
|
||||
}
|
||||
|
||||
return UsersRichText(
|
||||
preSpan: hasUser && fromNpub != kFranzapNpub
|
||||
preSpan: hasUser && fromNpub != kFranzapPubkey.npub
|
||||
? TextSpan(text: 'You, ')
|
||||
: null,
|
||||
trailingText: ' and others follow this signer on nostr.',
|
||||
|
||||
Reference in New Issue
Block a user