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
8 changes: 4 additions & 4 deletions lib/backends/backend.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import 'package:outlet/core/flatpak_application.dart';
import 'package:outlet/appstream.dart/lib/appstream.dart';

interface class Backend {
List<String> getInstalledPackages() {
return [];
Map<String, bool> getInstalledPackages() {
return {};
}

Future<Map<String, Application>> getAllRemotePackages() async {
Expand Down Expand Up @@ -69,8 +69,8 @@ class TestBackend implements Backend {
}

@override
List<String> getInstalledPackages() {
return ['app-3', 'app-7'];
Map<String, bool> getInstalledPackages() {
return {'app-3': true, 'app-7': false};
}

@override
Expand Down
9 changes: 6 additions & 3 deletions lib/backends/flatpak_backend.dart
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,13 @@ class FlatpakBackend implements Backend {
}

@override
List<String> getInstalledPackages() {
Map<String, bool> getInstalledPackages() {
final FlatpakBindings bindings =
FlatpakBindings(ffi.DynamicLibrary.open('libflatpak.so'));
ffi.Pointer<FlatpakInstallation> installationPtr = getFlatpakInstallation();
ffi.Pointer<ffi.Pointer<GError>> error =
pkg_ffi.calloc<ffi.Pointer<GError>>();
List<String> apps = [];
Map<String, bool> apps = {};
final ffi.Pointer<GPtrArray> installedRefsPtr =
bindings.flatpak_installation_list_installed_refs(
installationPtr, ffi.nullptr, error);
Expand All @@ -70,6 +70,9 @@ class FlatpakBackend implements Backend {
error,
);
if (error.value == ffi.nullptr) {
final current =
bindings.flatpak_installed_ref_get_is_current(installedRefPtr) ==
1;
final int refAppSize = bindings.g_bytes_get_size(refAppPtr);
final sizeP = pkg_ffi.malloc<gsize>();
sizeP.value = refAppSize;
Expand All @@ -96,7 +99,7 @@ class FlatpakBackend implements Backend {
continue;
}

apps.add(id);
apps[id] = current;
} on XmlParserException catch (e) {
logger.e('Error parsing XML: $e');
}
Expand Down
4 changes: 2 additions & 2 deletions lib/core/application.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@ class Application extends AppstreamComponent {
this.installed = false,
this.remote,
this.version,
this.current,
this.current = true,
}) : super(name: name ?? {"C": id});

bool featured;
bool installed;
final String? remote;
final String? version;
bool? current;
bool current;

String getLocalizedName() {
final key = bestLanguageKey(name);
Expand Down
2 changes: 1 addition & 1 deletion lib/core/flatpak_application.dart
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ class FlatpakApplication extends Application {
}

@override
getUpdateTarget() => id;
getUpdateTarget() => bundles.firstOrNull?.id ?? id;

@override
String launchCommand() {
Expand Down
2 changes: 1 addition & 1 deletion lib/providers/action_queue.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import 'package:outlet/providers/application_provider.dart';

class ActionQueueNotifier extends AutoDisposeNotifier<ActionQueueStatus> {
final Queue<Action> _queue = Queue();
final List<String> _completedActions = [];
final Set<String> _completedActions = {};
Action? _currentAction;
bool _isExecuting = false;

Expand Down
16 changes: 8 additions & 8 deletions lib/providers/application_provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@ final remoteAppListProvider =
});

final installedAppListProvider =
AutoDisposeNotifierProvider<InstalledAppListNotifier, List<String>>(
AutoDisposeNotifierProvider<InstalledAppListNotifier, Map<String, bool>>(
InstalledAppListNotifier.new);

class InstalledAppListNotifier extends AutoDisposeNotifier<List<String>> {
List<String> _getInstalledPackages() {
class InstalledAppListNotifier extends AutoDisposeNotifier<Map<String, bool>> {
Map<String, bool> _getInstalledPackages() {
final backend = ref.read(backendProvider);
Map<String, String> env = Platform.environment;
List<String> apps = [];
Map<String, bool> apps = {};

if (env['TEST_BACKEND_ENABLED'] != null) {
return backend.getInstalledPackages();
Expand All @@ -46,7 +46,7 @@ class InstalledAppListNotifier extends AutoDisposeNotifier<List<String>> {
}

@override
List<String> build() {
Map<String, bool> build() {
return _getInstalledPackages();
}

Expand Down Expand Up @@ -79,10 +79,10 @@ final appListProvider = Provider((ref) {
final installedApps = ref.watch(installedAppListProvider);
final featuredApps = ref.watch(featuredAppList);

// if (installedApps.hasValue)
for (var app in installedApps) {
for (var app in installedApps.entries) {
try {
remoteApps[app]!.installed = true;
remoteApps[app.key]!.installed = true;
remoteApps[app.key]!.current = app.value;
} catch (e) {
logger.w('Failed to find $app in installed list.');
}
Expand Down
8 changes: 4 additions & 4 deletions lib/views/components/app_actions.dart
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ class AppActions extends ConsumerWidget {
"installTarget": app.getInstallTarget(),
"remote": app.remote!
};
actionQueue.add("Installing ${app.name}", app.id,
_installWorker, data);
actionQueue.add("Installing ${app.getLocalizedName()}",
app.id, _installWorker, data);
}
},
style: const ButtonStyle(
Expand Down Expand Up @@ -97,8 +97,8 @@ class AppActions extends ConsumerWidget {
TextButton(
onPressed: () async {
final data = {"updateTarget": app.getUpdateTarget()};
actionQueue.add(
"Updating ${app.name}", app.id, _updateWorker, data);
actionQueue.add("Updating ${app.getLocalizedName()}",
app.id, _updateWorker, data);
},
style: const ButtonStyle(
backgroundColor:
Expand Down