From 358d2b5b932d64c6ac6889eb1e93afafd5ef1bff Mon Sep 17 00:00:00 2001 From: jld3103 Date: Sun, 27 Aug 2023 22:25:44 +0200 Subject: [PATCH] refactor(neon,neon_files): Refactor platform path getters Signed-off-by: jld3103 --- packages/neon/neon/lib/src/platform/android.dart | 4 ++-- packages/neon/neon/lib/src/platform/linux.dart | 4 ++-- packages/neon/neon/lib/src/platform/platform.dart | 4 ++-- packages/neon/neon/lib/src/utils/request_manager.dart | 2 +- packages/neon/neon_files/lib/blocs/files.dart | 4 ++-- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/packages/neon/neon/lib/src/platform/android.dart b/packages/neon/neon/lib/src/platform/android.dart index 20450859..2ee8d3ea 100644 --- a/packages/neon/neon/lib/src/platform/android.dart +++ b/packages/neon/neon/lib/src/platform/android.dart @@ -29,13 +29,13 @@ class AndroidNeonPlatform implements NeonPlatform { bool get canUseWindowManager => false; @override - Future getApplicationCachePath() async { + Future get applicationCachePath async { final tempDir = await getTemporaryDirectory(); return tempDir.absolute.path; } @override - Future getUserAccessibleAppDataPath() async { + Future get userAccessibleAppDataPath async { if (!await Permission.storage.request().isGranted) { throw MissingPermissionException(Permission.storage); } diff --git a/packages/neon/neon/lib/src/platform/linux.dart b/packages/neon/neon/lib/src/platform/linux.dart index 0ec74e83..17c270a4 100644 --- a/packages/neon/neon/lib/src/platform/linux.dart +++ b/packages/neon/neon/lib/src/platform/linux.dart @@ -30,13 +30,13 @@ class LinuxNeonPlatform implements NeonPlatform { bool get canUsePushNotifications => false; @override - String getApplicationCachePath() => p.join( + String get applicationCachePath => p.join( xdg.cacheHome.absolute.path, 'de.provokateurin.neon', ); @override - String getUserAccessibleAppDataPath() => p.join(Platform.environment['HOME']!, 'Neon'); + String get userAccessibleAppDataPath => p.join(Platform.environment['HOME']!, 'Neon'); @override void init() { diff --git a/packages/neon/neon/lib/src/platform/platform.dart b/packages/neon/neon/lib/src/platform/platform.dart index 318c1a3e..85eb196a 100644 --- a/packages/neon/neon/lib/src/platform/platform.dart +++ b/packages/neon/neon/lib/src/platform/platform.dart @@ -53,9 +53,9 @@ abstract interface class NeonPlatform { abstract final bool canUsePushNotifications; - FutureOr getApplicationCachePath(); + FutureOr get applicationCachePath; - FutureOr getUserAccessibleAppDataPath(); + FutureOr get userAccessibleAppDataPath; FutureOr init(); } diff --git a/packages/neon/neon/lib/src/utils/request_manager.dart b/packages/neon/neon/lib/src/utils/request_manager.dart index bccfd985..e29954e3 100644 --- a/packages/neon/neon/lib/src/utils/request_manager.dart +++ b/packages/neon/neon/lib/src/utils/request_manager.dart @@ -196,7 +196,7 @@ class Cache { _database = await openDatabase( p.join( - await NeonPlatform.instance.getApplicationCachePath(), + await NeonPlatform.instance.applicationCachePath, 'cache.db', ), version: 1, diff --git a/packages/neon/neon_files/lib/blocs/files.dart b/packages/neon/neon_files/lib/blocs/files.dart index fc86e497..9946c131 100644 --- a/packages/neon/neon_files/lib/blocs/files.dart +++ b/packages/neon/neon_files/lib/blocs/files.dart @@ -84,7 +84,7 @@ class FilesBloc extends InteractiveBloc implements FilesBlocEvents, FilesBlocSta () async { final file = File( p.join( - await NeonPlatform.instance.getApplicationCachePath(), + await NeonPlatform.instance.applicationCachePath, 'files', etag.replaceAll('"', ''), path.last, @@ -137,7 +137,7 @@ class FilesBloc extends InteractiveBloc implements FilesBlocEvents, FilesBlocSta () async { final file = File( p.join( - await NeonPlatform.instance.getUserAccessibleAppDataPath(), + await NeonPlatform.instance.userAccessibleAppDataPath, account.humanReadableID, 'files', path.join(Platform.pathSeparator),