diff --git a/mobile/lib/db/files_db.dart b/mobile/lib/db/files_db.dart index 2fe4f5db6..51323bf2a 100644 --- a/mobile/lib/db/files_db.dart +++ b/mobile/lib/db/files_db.dart @@ -106,6 +106,7 @@ class FilesDB { static Future? _ffiDBFuture; static Future? _sqliteAsyncDBFuture; + @Deprecated("Use ffiDB instead (sqlite_async)") Future get database async { // lazily instantiate the db the first time it is accessed _dbFuture ??= _initDatabase(); @@ -478,8 +479,8 @@ class FilesDB { } Future getFile(int generatedID) async { - final db = await instance.ffiDB; - final results = db.select( + final db = await instance.sqliteAsyncDB; + final results = await db.getAll( 'SELECT * FROM $filesTable WHERE $columnGeneratedID = ?', [generatedID], ); @@ -490,8 +491,8 @@ class FilesDB { } Future getUploadedFile(int uploadedID, int collectionID) async { - final db = await instance.ffiDB; - final results = db.select( + final db = await instance.sqliteAsyncDB; + final results = await db.getAll( 'SELECT * FROM $filesTable WHERE $columnUploadedFileID = ? AND $columnCollectionID = ?', [ uploadedID, @@ -505,8 +506,8 @@ class FilesDB { } Future> getUploadedFileIDs(int collectionID) async { - final db = await instance.ffiDB; - final results = db.select( + final db = await instance.sqliteAsyncDB; + final results = await db.getAll( 'SELECT $columnUploadedFileID FROM $filesTable' ' WHERE $columnCollectionID = ? AND ($columnUploadedFileID IS NOT NULL AND $columnUploadedFileID IS NOT -1)', [ @@ -756,41 +757,6 @@ class FilesDB { final results = await db.getAll( query, ); - - final files = convertToFiles(results); - return applyDBFilters( - files, - DBFilterOptions(ignoredCollectionIDs: ignoredCollectionIDs), - ); - } - - Future> getFilesCreatedWithinDurationsSync( - List> durations, - Set ignoredCollectionIDs, { - int? visibility, - String order = 'ASC', - }) async { - if (durations.isEmpty) { - return []; - } - final db = await instance.ffiDB; - String whereClause = "( "; - for (int index = 0; index < durations.length; index++) { - whereClause += "($columnCreationTime >= " + - durations[index][0].toString() + - " AND $columnCreationTime < " + - durations[index][1].toString() + - ")"; - if (index != durations.length - 1) { - whereClause += " OR "; - } else if (visibility != null) { - whereClause += ' AND $columnMMdVisibility = $visibility'; - } - } - whereClause += ")"; - final results = db.select( - 'select * from $filesTable where $whereClause order by $columnCreationTime $order', - ); final files = convertToFiles(results); return applyDBFilters( files, diff --git a/mobile/lib/services/memories_service.dart b/mobile/lib/services/memories_service.dart index de68e2dab..646113128 100644 --- a/mobile/lib/services/memories_service.dart +++ b/mobile/lib/services/memories_service.dart @@ -107,7 +107,7 @@ class MemoriesService extends ChangeNotifier { } final ignoredCollections = CollectionsService.instance.archivedOrHiddenCollectionIds(); - final files = await _filesDB.getFilesCreatedWithinDurationsSync( + final files = await _filesDB.getFilesCreatedWithinDurations( durations, ignoredCollections, visibility: visibleVisibility, diff --git a/mobile/pubspec.lock b/mobile/pubspec.lock index 393dadc23..d40f8b0c4 100644 --- a/mobile/pubspec.lock +++ b/mobile/pubspec.lock @@ -2039,7 +2039,7 @@ packages: source: hosted version: "0.3.0" sqlite3: - dependency: "direct main" + dependency: transitive description: name: sqlite3 sha256: "072128763f1547e3e9b4735ce846bfd226d68019ccda54db4cd427b12dfdedc9" diff --git a/mobile/pubspec.yaml b/mobile/pubspec.yaml index 89bee933b..9f6e7065c 100644 --- a/mobile/pubspec.yaml +++ b/mobile/pubspec.yaml @@ -140,7 +140,6 @@ dependencies: shared_preferences: ^2.0.5 sqflite: ^2.3.0 sqflite_migration: ^0.3.0 - sqlite3: ^2.1.0 sqlite3_flutter_libs: ^0.5.20 sqlite_async: ^0.6.1 step_progress_indicator: ^1.0.2