ente/lib/models/files_split.dart

37 lines
999 B
Dart
Raw Normal View History

2023-01-05 04:04:34 +00:00
import 'package:photos/models/file.dart';
class FilesSplit {
final List<File> pendingUploads;
final List<File> ownedByCurrentUser;
final List<File> ownedByOtherUsers;
FilesSplit({
required this.pendingUploads,
required this.ownedByCurrentUser,
required this.ownedByOtherUsers,
});
int get totalFileOwnedCount =>
pendingUploads.length + ownedByCurrentUser.length;
2023-01-05 11:14:28 +00:00
static FilesSplit split(Iterable<File> files, int currentUserID) {
2023-01-05 04:04:34 +00:00
final List<File> ownedByCurrentUser = [],
ownedByOtherUsers = [],
pendingUploads = [];
for (var f in files) {
if (f.ownerID == null || f.uploadedFileID == null) {
pendingUploads.add(f);
} else if (f.ownerID == currentUserID) {
ownedByCurrentUser.add(f);
} else {
ownedByOtherUsers.add(f);
}
}
2023-01-05 11:14:28 +00:00
return FilesSplit(
pendingUploads: pendingUploads,
ownedByCurrentUser: ownedByCurrentUser,
ownedByOtherUsers: ownedByOtherUsers,
);
2023-01-05 04:04:34 +00:00
}
2023-01-05 04:29:17 +00:00
}