Fix thumbnail issue within device folder section
This commit is contained in:
parent
3f084bb38c
commit
f17d7027c8
2 changed files with 23 additions and 16 deletions
|
@ -461,6 +461,7 @@ class FilesDB {
|
|||
final rows = await db.query(
|
||||
table,
|
||||
columns: [columnDeviceFolder],
|
||||
where: '$columnLocalID IS NOT NULL',
|
||||
distinct: true,
|
||||
);
|
||||
List<String> result = List<String>();
|
||||
|
@ -486,6 +487,22 @@ class FilesDB {
|
|||
}
|
||||
}
|
||||
|
||||
Future<File> getLastCreatedFileInPath(String path) async {
|
||||
final db = await instance.database;
|
||||
final rows = await db.query(
|
||||
table,
|
||||
where: '$columnDeviceFolder = ? AND $columnIsDeleted = 0',
|
||||
whereArgs: [path],
|
||||
orderBy: '$columnCreationTime DESC',
|
||||
limit: 1,
|
||||
);
|
||||
if (rows.isNotEmpty) {
|
||||
return _getFileFromRow(rows[0]);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
Future<File> getLastModifiedFileInCollection(int collectionID) async {
|
||||
final db = await instance.database;
|
||||
final rows = await db.query(
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
import 'dart:async';
|
||||
import 'dart:collection';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
|
@ -110,26 +109,17 @@ class _CollectionsGalleryWidgetState extends State<CollectionsGalleryWidget>
|
|||
|
||||
Future<CollectionItems> _getCollections() async {
|
||||
final filesDB = FilesDB.instance;
|
||||
final filesRepo = FileRepository.instance;
|
||||
final collectionsService = CollectionsService.instance;
|
||||
final userID = Configuration.instance.getUserID();
|
||||
final folders = List<DeviceFolder>();
|
||||
final files = filesRepo.hasLoadedFiles
|
||||
? filesRepo.files
|
||||
: await filesRepo.loadFiles();
|
||||
final thumbnailPathMap = Map<String, File>();
|
||||
for (final file in files) {
|
||||
final path = file.deviceFolder;
|
||||
if (file.localID != null) {
|
||||
if (thumbnailPathMap[path] == null) {
|
||||
thumbnailPathMap[path] = file;
|
||||
}
|
||||
}
|
||||
}
|
||||
for (final path in thumbnailPathMap.keys) {
|
||||
final paths = await filesDB.getLocalPaths();
|
||||
for (final path in paths) {
|
||||
final folderName = p.basename(path);
|
||||
folders.add(DeviceFolder(folderName, path, thumbnailPathMap[path]));
|
||||
folders.add(DeviceFolder(
|
||||
folderName, path, await filesDB.getLastCreatedFileInPath(path)));
|
||||
}
|
||||
folders.sort((first, second) =>
|
||||
second.thumbnail.creationTime.compareTo(first.thumbnail.creationTime));
|
||||
final collectionsWithThumbnail = List<CollectionWithThumbnail>();
|
||||
final collections = collectionsService.getCollections();
|
||||
final ownedCollectionIDs = List<int>();
|
||||
|
|
Loading…
Add table
Reference in a new issue