Merge pull request #337 from ente-io/hide_hidden_memories

Hide hidden memories from memories widget 🍭
This commit is contained in:
Manav 2022-06-21 18:48:31 +05:30 committed by GitHub
commit 82c26ef1c9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 20 additions and 21 deletions

View file

@ -580,9 +580,10 @@ class FilesDB {
Future<List<File>> getFilesCreatedWithinDurations(
List<List<int>> durations,
Set<int> ignoredCollectionIDs,
) async {
final db = await instance.database;
String whereClause = "";
String whereClause = "( ";
for (int index = 0; index < durations.length; index++) {
whereClause += "($columnCreationTime > " +
durations[index][0].toString() +
@ -593,12 +594,14 @@ class FilesDB {
whereClause += " OR ";
}
}
whereClause += ") AND $columnMMdVisibility = $kVisibilityVisible";
final results = await db.query(
table,
where: whereClause,
orderBy: '$columnCreationTime ASC',
);
return _convertToFiles(results);
final files = _convertToFiles(results);
return _deduplicatedAndFilterIgnoredFiles(files, ignoredCollectionIDs);
}
Future<List<File>> getFilesToBeUploadedWithinFolders(

View file

@ -10,25 +10,17 @@ class ImportantItemsFilter implements GalleryItemsFilter {
@override
bool shouldInclude(File file) {
if (_importantPaths.isEmpty) {
if (Platform.isAndroid) {
if (file.uploadedFileID != null) {
return true;
}
final String folder = basename(file.deviceFolder);
return folder == "Camera" ||
folder == "Recents" ||
folder == "DCIM" ||
folder == "Download" ||
folder == "Screenshot";
} else {
return true;
}
}
if (file.uploadedFileID != null) {
return true;
}
final folder = basename(file.deviceFolder);
final String folder = basename(file.deviceFolder);
if (_importantPaths.isEmpty && Platform.isAndroid) {
return folder == "Camera" ||
folder == "Recents" ||
folder == "DCIM" ||
folder == "Download" ||
folder == "Screenshot";
}
return _importantPaths.contains(folder);
}
}

View file

@ -5,6 +5,7 @@ import 'package:photos/db/files_db.dart';
import 'package:photos/db/memories_db.dart';
import 'package:photos/models/filters/important_items_filter.dart';
import 'package:photos/models/memory.dart';
import 'package:photos/services/collections_service.dart';
class MemoriesService extends ChangeNotifier {
final _logger = Logger("MemoryService");
@ -70,7 +71,10 @@ class MemoriesService extends ChangeNotifier {
date.add(Duration(days: daysAfter)).microsecondsSinceEpoch;
durations.add([startCreationTime, endCreationTime]);
}
final files = await _filesDB.getFilesCreatedWithinDurations(durations);
final archivedCollectionIds =
CollectionsService.instance.getArchivedCollections();
final files = await _filesDB.getFilesCreatedWithinDurations(
durations, archivedCollectionIds);
final seenTimes = await _memoriesDB.getSeenTimes();
final List<Memory> memories = [];
final filter = ImportantItemsFilter();

View file

@ -334,8 +334,8 @@ class _FullScreenMemoryState extends State<FullScreenMemory> {
child: IconButton(
icon: Icon(
Icons.adaptive.share,
color: Colors.white,
), //same for both themes
color: Colors.white, //same for both themes
),
onPressed: () {
share(context, [file]);
},