Browse Source

refactor(neon,neon_files): Refactor platform path getters

Signed-off-by: jld3103 <jld3103yt@gmail.com>
pull/495/head
jld3103 1 year ago
parent
commit
358d2b5b93
No known key found for this signature in database
GPG Key ID: 9062417B9E8EB7B3
  1. 4
      packages/neon/neon/lib/src/platform/android.dart
  2. 4
      packages/neon/neon/lib/src/platform/linux.dart
  3. 4
      packages/neon/neon/lib/src/platform/platform.dart
  4. 2
      packages/neon/neon/lib/src/utils/request_manager.dart
  5. 4
      packages/neon/neon_files/lib/blocs/files.dart

4
packages/neon/neon/lib/src/platform/android.dart

@ -29,13 +29,13 @@ class AndroidNeonPlatform implements NeonPlatform {
bool get canUseWindowManager => false;
@override
Future<String> getApplicationCachePath() async {
Future<String> get applicationCachePath async {
final tempDir = await getTemporaryDirectory();
return tempDir.absolute.path;
}
@override
Future<String> getUserAccessibleAppDataPath() async {
Future<String> get userAccessibleAppDataPath async {
if (!await Permission.storage.request().isGranted) {
throw MissingPermissionException(Permission.storage);
}

4
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() {

4
packages/neon/neon/lib/src/platform/platform.dart

@ -53,9 +53,9 @@ abstract interface class NeonPlatform {
abstract final bool canUsePushNotifications;
FutureOr<String> getApplicationCachePath();
FutureOr<String> get applicationCachePath;
FutureOr<String> getUserAccessibleAppDataPath();
FutureOr<String> get userAccessibleAppDataPath;
FutureOr init();
}

2
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,

4
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),

Loading…
Cancel
Save