From 4dbf9c8078930357ce0130ee612544de829dc24b Mon Sep 17 00:00:00 2001 From: Vishnu Mohandas Date: Thu, 28 May 2020 02:33:30 +0530 Subject: [PATCH] Hide remote folders in the gallery section --- lib/db/photo_db.dart | 7 ++++++- lib/ui/device_folders_gallery_widget.dart | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/db/photo_db.dart b/lib/db/photo_db.dart index 04e75c6e9..23db968e8 100644 --- a/lib/db/photo_db.dart +++ b/lib/db/photo_db.dart @@ -1,5 +1,6 @@ import 'dart:io'; +import 'package:logging/logging.dart'; import 'package:photos/models/photo.dart'; import 'package:path/path.dart'; import 'package:sqflite/sqflite.dart'; @@ -10,6 +11,8 @@ class PhotoDB { static final _databaseName = "ente.photos.db"; static final _databaseVersion = 1; + static final Logger _logger = Logger("PhotoDB"); + static final table = 'photos'; static final columnGeneratedId = '_id'; @@ -202,12 +205,13 @@ class PhotoDB { ); } - Future> getDistinctPaths() async { + Future> getLocalPaths() async { final db = await instance.database; final rows = await db.query( table, columns: [columnDeviceFolder], distinct: true, + where: '$columnRemoteFolderId IS NULL', ); List result = List(); for (final row in rows) { @@ -233,6 +237,7 @@ class PhotoDB { } Future getLatestPhotoInRemoteFolder(int folderId) async { + _logger.info("Querying for folder: " + folderId.toString()); final db = await instance.database; var rows = await db.query( table, diff --git a/lib/ui/device_folders_gallery_widget.dart b/lib/ui/device_folders_gallery_widget.dart index 7c67519f2..21ef8edcb 100644 --- a/lib/ui/device_folders_gallery_widget.dart +++ b/lib/ui/device_folders_gallery_widget.dart @@ -54,7 +54,7 @@ class _DeviceFolderGalleryWidgetState extends State { } Future> _getDeviceFolders() async { - final paths = await PhotoDB.instance.getDistinctPaths(); + final paths = await PhotoDB.instance.getLocalPaths(); final folders = List(); for (final path in paths) { final photo = await PhotoDB.instance.getLatestPhotoInPath(path);