-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(neon_framework): migrate to neon_storage
Signed-off-by: Nikolas Rimikis <[email protected]>
- Loading branch information
Showing
42 changed files
with
249 additions
and
1,477 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
packages/neon_framework/lib/src/storage/neon_cache_db.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import 'dart:async'; | ||
|
||
import 'package:cookie_store/cookie_store.dart'; | ||
import 'package:flutter/foundation.dart'; | ||
import 'package:neon_storage/neon_sqlite.dart'; | ||
import 'package:neon_storage/neon_storage.dart'; | ||
|
||
import 'package:path_provider/path_provider.dart'; | ||
|
||
/// Database holding the neon cache. | ||
final class NeonCacheDB extends MultiTableDatabase { | ||
/// Creates a new database with the given [tables]. | ||
factory NeonCacheDB({ | ||
Iterable<Table>? tables, | ||
}) { | ||
return NeonCacheDB._( | ||
tables: [ | ||
...?tables, | ||
if (!kIsWeb) SQLiteRequestCache.table, | ||
if (!kIsWeb) SQLiteCookiePersistence.table, | ||
], | ||
); | ||
} | ||
|
||
NeonCacheDB._({ | ||
required super.tables, | ||
}); | ||
|
||
@override | ||
String get name => 'cache'; | ||
|
||
@override | ||
Future<String> get path async { | ||
final cacheDir = await getApplicationCacheDirectory(); | ||
|
||
return buildDatabasePath(cacheDir.path, name); | ||
} | ||
|
||
/// The current request cache if available. | ||
RequestCache? get requestCache { | ||
if (kIsWeb) { | ||
return null; | ||
} | ||
|
||
assertInitialized(); | ||
|
||
return const SQLiteRequestCache(); | ||
} | ||
|
||
/// Creates a new `CookieStore` scoped to the given [accountID] and [serverURL]. | ||
/// | ||
/// Cookies will only be sent to cookies matching the [serverURL]. | ||
CookieStore? cookieStore({required String accountID, required Uri serverURL}) { | ||
if (kIsWeb) { | ||
return null; | ||
} | ||
|
||
assertInitialized(); | ||
|
||
final persistence = SQLiteCookiePersistence( | ||
accountID: accountID, | ||
allowedBaseUri: serverURL, | ||
); | ||
|
||
return DefaultCookieStore(persistence); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import 'dart:async'; | ||
|
||
import 'package:neon_storage/neon_sqlite.dart'; | ||
import 'package:neon_storage/neon_storage.dart'; | ||
import 'package:path_provider/path_provider.dart'; | ||
|
||
/// Database holding the neon data. | ||
final class NeonDataDB extends MultiTableDatabase { | ||
/// Creates a new database with the given [tables]. | ||
factory NeonDataDB({ | ||
Iterable<Table>? tables, | ||
}) { | ||
return NeonDataDB._( | ||
tables: [ | ||
...?tables, | ||
SQLiteCachedPersistence.table, | ||
], | ||
); | ||
} | ||
|
||
NeonDataDB._({ | ||
required super.tables, | ||
}); | ||
|
||
@override | ||
String get name => 'preferences'; | ||
|
||
@override | ||
Future<String> get path async { | ||
final cacheDir = await getApplicationSupportDirectory(); | ||
|
||
return buildDatabasePath(cacheDir.path, name); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.