hide ignored files from home page
This commit is contained in:
parent
f0085c0889
commit
f8c85c6fe9
2 changed files with 15 additions and 2 deletions
|
@ -9,6 +9,7 @@ import 'package:photos/models/file_load_result.dart';
|
||||||
import 'package:photos/models/file_type.dart';
|
import 'package:photos/models/file_type.dart';
|
||||||
import 'package:photos/models/location.dart';
|
import 'package:photos/models/location.dart';
|
||||||
import 'package:photos/models/magic_metadata.dart';
|
import 'package:photos/models/magic_metadata.dart';
|
||||||
|
import 'package:photos/services/ignored_files_service.dart';
|
||||||
import 'package:sqflite/sqflite.dart';
|
import 'package:sqflite/sqflite.dart';
|
||||||
import 'package:sqflite_migration/sqflite_migration.dart';
|
import 'package:sqflite_migration/sqflite_migration.dart';
|
||||||
|
|
||||||
|
@ -433,7 +434,9 @@ class FilesDB {
|
||||||
limit: limit,
|
limit: limit,
|
||||||
);
|
);
|
||||||
final files = _convertToFiles(results);
|
final files = _convertToFiles(results);
|
||||||
return FileLoadResult(files, files.length == limit);
|
final hasMore = files.length == limit;
|
||||||
|
await _removeLocalIgnoredFiles(files);
|
||||||
|
return FileLoadResult(files, hasMore);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<FileLoadResult> getImportantFiles(
|
Future<FileLoadResult> getImportantFiles(
|
||||||
|
@ -457,8 +460,17 @@ class FilesDB {
|
||||||
limit: limit,
|
limit: limit,
|
||||||
);
|
);
|
||||||
final files = _convertToFiles(results);
|
final files = _convertToFiles(results);
|
||||||
|
final hasMore = files.length == limit;
|
||||||
List<File> deduplicatedFiles = _deduplicatedFiles(files);
|
List<File> deduplicatedFiles = _deduplicatedFiles(files);
|
||||||
return FileLoadResult(deduplicatedFiles, files.length == limit);
|
await _removeLocalIgnoredFiles(deduplicatedFiles);
|
||||||
|
return FileLoadResult(deduplicatedFiles, hasMore);
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _removeLocalIgnoredFiles(List<File> files) async {
|
||||||
|
final ignoredIDs = await IgnoredFilesService.instance.ignoredIDs;
|
||||||
|
files.removeWhere((f) =>
|
||||||
|
f.uploadedFileID == null &&
|
||||||
|
IgnoredFilesService.instance.shouldSkipUpload(ignoredIDs, f));
|
||||||
}
|
}
|
||||||
|
|
||||||
List<File> _deduplicatedFiles(List<File> files) {
|
List<File> _deduplicatedFiles(List<File> files) {
|
||||||
|
|
|
@ -41,6 +41,7 @@ class IgnoredFilesService {
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<Set<String>> _loadExistingIDs() async {
|
Future<Set<String>> _loadExistingIDs() async {
|
||||||
|
_logger.fine('loading existing IDs');
|
||||||
final result = await _db.getAll();
|
final result = await _db.getAll();
|
||||||
return result.map((e) => _iDForIgnoredFile(e)).toSet();
|
return result.map((e) => _iDForIgnoredFile(e)).toSet();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue