mirror of
https://github.com/zapstore/zapstore.git
synced 2026-10-06 04:58:23 +00:00
Fix app detail refresh, search bug and clear results
This commit is contained in:
+32
-17
@@ -78,6 +78,23 @@ mixin AppAdapter on Adapter<App> {
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
Future<List<App>> loadAppModels(Map<String, dynamic> params) async {
|
||||
final apps = await super.findAll(params: params);
|
||||
final releases =
|
||||
await ref.releases.findAll(params: {'#a': apps.map((app) => app.aTag)});
|
||||
final metadataIds = releases.map((r) => r.tagMap['e']!).expand((_) => _);
|
||||
await ref.fileMetadata.findAll(params: {
|
||||
'ids': metadataIds,
|
||||
'#m': [kAndroidMimeType]
|
||||
});
|
||||
final userIds = {
|
||||
for (final app in apps) app.signer.id,
|
||||
for (final app in apps) app.developer.id
|
||||
}.nonNulls;
|
||||
await ref.users.findAll(params: {'authors': userIds});
|
||||
return apps;
|
||||
}
|
||||
|
||||
@override
|
||||
Future<List<App>> findAll(
|
||||
{bool? remote = true,
|
||||
@@ -90,23 +107,6 @@ mixin AppAdapter on Adapter<App> {
|
||||
DataRequestLabel? label}) async {
|
||||
final map = await getInstalledAppsMap();
|
||||
|
||||
loadAppModels(Map<String, dynamic> params) async {
|
||||
final apps = await super.findAll(params: params);
|
||||
final releases = await ref.releases
|
||||
.findAll(params: {'#a': apps.map((app) => app.aTag)});
|
||||
final metadataIds = releases.map((r) => r.tagMap['e']!).expand((_) => _);
|
||||
await ref.fileMetadata.findAll(params: {
|
||||
'ids': metadataIds,
|
||||
'#m': [kAndroidMimeType]
|
||||
});
|
||||
final userIds = {
|
||||
for (final app in apps) app.signer.id,
|
||||
for (final app in apps) app.developer.id
|
||||
}.nonNulls;
|
||||
await ref.users.findAll(params: {'authors': userIds});
|
||||
return apps;
|
||||
}
|
||||
|
||||
if (params!.containsKey('installed')) {
|
||||
if (map.keys.isNotEmpty) {
|
||||
params['#d'] = map.keys;
|
||||
@@ -125,6 +125,21 @@ mixin AppAdapter on Adapter<App> {
|
||||
return loadAppModels(params);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<App?> findOne(Object id,
|
||||
{bool remote = true,
|
||||
bool background = false,
|
||||
Map<String, dynamic>? params = const {},
|
||||
Map<String, String>? headers,
|
||||
OnSuccessOne<App>? onSuccess,
|
||||
OnErrorOne<App>? onError,
|
||||
DataRequestLabel? label}) async {
|
||||
final apps = await loadAppModels({
|
||||
'#d': [id]
|
||||
});
|
||||
return apps.firstOrNull;
|
||||
}
|
||||
|
||||
static AndroidPackageManager? _packageManager;
|
||||
|
||||
Future<Map<String, String>> getInstalledAppsMap() async {
|
||||
|
||||
@@ -60,7 +60,11 @@ class SearchScreen extends HookConsumerWidget {
|
||||
IconButton(
|
||||
hoverColor: Colors.transparent,
|
||||
onPressed: () {
|
||||
// clear input and results, then return focus
|
||||
controller.clear();
|
||||
ref
|
||||
.read(searchStateProvider.notifier)
|
||||
.updateWith(model: <App>[]);
|
||||
focusNode.requestFocus();
|
||||
},
|
||||
icon: Icon(Icons.close),
|
||||
@@ -132,7 +136,7 @@ final searchStateProvider = StateNotifierProvider.autoDispose<
|
||||
(app.url ?? '').contains(r) ||
|
||||
app.name!.contains(r) ||
|
||||
app.content.contains(r) ||
|
||||
app.tags.any((e) => e.contains(r)))
|
||||
app.tags.any((e) => e[1].contains(r)))
|
||||
.toList();
|
||||
n.updateWith(model: apps, isLoading: false);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user