Correctly filter map browser query

This commit is contained in:
Ming Ming 2024-07-15 01:17:50 +08:00
parent 7cae2827c7
commit 4bb825a7dc
3 changed files with 22 additions and 1 deletions

View file

@ -1,7 +1,11 @@
import 'package:logging/logging.dart';
import 'package:nc_photos/account.dart';
import 'package:nc_photos/db/entity_converter.dart';
import 'package:nc_photos/entity/file.dart';
import 'package:nc_photos/entity/file_descriptor.dart';
import 'package:nc_photos/entity/file_util.dart' as file_util;
import 'package:nc_photos/entity/image_location/repo.dart';
import 'package:nc_photos/remote_storage_util.dart' as remote_storage_util;
import 'package:np_async/np_async.dart';
import 'package:np_codegen/np_codegen.dart';
import 'package:np_db/np_db.dart';
@ -15,7 +19,15 @@ class ImageLocationNpDbDataSource implements ImageLocationDataSource {
@override
Future<List<ImageLatLng>> getLocations(Account account) async {
_log.info("[getLocations]");
final results = await db.getImageLatLngWithFileIds(account: account.toDb());
final results = await db.getImageLatLngWithFileIds(
account: account.toDb(),
includeRelativeRoots: account.roots
.map((e) => File(path: file_util.unstripPath(account, e))
.strippedPathWithEmpty)
.toList(),
excludeRelativeRoots: [remote_storage_util.remoteStorageDirRelativePath],
mimes: file_util.supportedFormatMimes,
);
return results.computeAll(DbImageLatLngConverter.fromDb);
}

View file

@ -435,6 +435,9 @@ abstract class NpDb {
/// Return the latitude, longitude and the file id of all files
Future<List<DbImageLatLng>> getImageLatLngWithFileIds({
required DbAccount account,
List<String>? includeRelativeRoots,
List<String>? excludeRelativeRoots,
List<String>? mimes,
});
Future<List<DbNcAlbum>> getNcAlbums({

View file

@ -578,10 +578,16 @@ class NpDbSqlite implements NpDb {
@override
Future<List<DbImageLatLng>> getImageLatLngWithFileIds({
required DbAccount account,
List<String>? includeRelativeRoots,
List<String>? excludeRelativeRoots,
List<String>? mimes,
}) async {
final sqlObjs = await _db.use((db) async {
return await db.queryImageLatLngWithFileIds(
account: ByAccount.db(account),
includeRelativeRoots: includeRelativeRoots,
excludeRelativeRoots: excludeRelativeRoots,
mimes: mimes,
);
});
return sqlObjs.computeAll((e) => DbImageLatLng(