diff --git a/lib/db/files_db.dart b/lib/db/files_db.dart index ea762b2b4..5a18cc828 100644 --- a/lib/db/files_db.dart +++ b/lib/db/files_db.dart @@ -117,16 +117,25 @@ class FilesDB { final db = await instance.database; final results = await db.query(table, where: '$columnGeneratedID = ?', whereArgs: [generatedID]); - return _convertToFiles(results)[0]; + final convertedResults = _convertToFiles(results); + if (convertedResults.length == 0) { + return null; + } else { + return convertedResults[1]; + } } Future> getOwnedFiles(int ownerID) async { final db = await instance.database; + final whereArgs = List(); + if (ownerID != null) { + whereArgs.add(ownerID); + } final results = await db.query( table, - where: '$columnIsDeleted = 0' + - (ownerID == null ? '' : ' AND $columnOwnerID = ?'), - whereArgs: [ownerID], + // where: '$columnIsDeleted = 0' + + // (ownerID == null ? '' : ' AND $columnOwnerID = ?'), + // whereArgs: whereArgs, orderBy: '$columnCreationTime DESC', ); return _convertToFiles(results);