Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions lib/core/application.dart
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,35 @@ class Application extends AppstreamComponent {
String getUpdateTarget() => id;

String launchCommand() => id;

Application copyWith({bool? installed, bool? current, bool? featured}) {
return Application(
id: id,
package: package,
name: name,
summary: summary,
description: description,
developerName: developerName,
projectLicense: projectLicense,
projectGroup: projectGroup,
icons: icons,
urls: urls,
categories: categories,
screenshots: screenshots,
keywords: keywords,
compulsoryForDesktops: compulsoryForDesktops,
releases: releases,
provides: provides,
contentRatings: contentRatings,
custom: custom,
installed: installed ?? this.installed,
bundles: bundles,
remote: remote,
type: type,
current: current ?? this.current,
featured: featured ?? this.featured,
);
}
}

extension _GetOrDefault<K, V> on Map<K, V> {
Expand Down
32 changes: 32 additions & 0 deletions lib/core/flatpak_application.dart
Original file line number Diff line number Diff line change
Expand Up @@ -164,4 +164,36 @@ class FlatpakApplication extends Application {
String launchCommand() {
return "flatpak run $id";
}

@override
FlatpakApplication copyWith(
{bool? installed, bool? current, bool? featured}) {
return FlatpakApplication(
id: id,
package: package,
name: name,
summary: summary,
description: description,
developerName: developerName,
projectLicense: projectLicense,
projectGroup: projectGroup,
icons: icons,
urls: urls,
categories: categories,
screenshots: screenshots,
keywords: keywords,
compulsoryForDesktops: compulsoryForDesktops,
releases: releases,
provides: provides,
contentRatings: contentRatings,
custom: custom,
installed: installed ?? this.installed,
bundles: bundles,
remote: remote,
type: type,
deployDir: deployDir,
current: current ?? this.current,
featured: featured ?? this.featured,
);
}
}
35 changes: 13 additions & 22 deletions lib/providers/application_provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -77,29 +77,18 @@ final featuredAppList = FutureProvider<List<String>>((ref) async {
final appListProvider = Provider((ref) {
final remoteApps = ref.watch(remoteAppListProvider).value ?? {};
final installedApps = ref.watch(installedAppListProvider);
final featuredApps = ref.watch(featuredAppList);

for (var app in installedApps.entries) {
try {
remoteApps[app.key]!.installed = true;
remoteApps[app.key]!.current = app.value;
} catch (e) {
logger.w('Failed to find $app in installed list.');
}
}
final featuredApps = ref.watch(featuredAppList).value ?? [];

if (featuredApps.hasValue) {
List<String> featured = featuredApps.value!;

for (var app in featured) {
try {
remoteApps[app]!.featured = true;
} catch (e) {
logger.w('Failed to find $app in featured list.');
}
}
}
return remoteApps;
return remoteApps.map((id, app) {
return MapEntry(
id,
app.copyWith(
installed: installedApps.containsKey(id),
current: installedApps[id] ?? false,
featured: featuredApps.contains(id),
),
);
});
});

final searchKeywordsProvider = Provider((ref) {
Expand All @@ -116,6 +105,8 @@ final liveApplicationProvider =
Provider.family<Application?, String>((ref, appId) {
final allApps = ref.watch(appListProvider);

logger.i('Refreshed provider for $appId');

return allApps[appId];
});

Expand Down
Loading