Change UploadModel::createAndAddUploadItem to not duplicate new uploadItems of same UploadableFile (#5179)

This commit is contained in:
Chan Jun Da 2023-03-16 09:19:24 +08:00 committed by GitHub
parent be1946cd7b
commit 66e15a17ef
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -117,6 +117,13 @@ public class UploadModel {
createdTimestampSource,
uploadableFile.getContentUri(),
fileCreatedDateString);
// If an uploadItem of the same uploadableFile has been created before, we return that.
// This is to avoid multiple instances of uploadItem of same file passed around.
if (items.contains(uploadItem)) {
return items.get(items.indexOf(uploadItem));
}
if (place != null) {
uploadItem.getUploadMediaDetails().set(0, new UploadMediaDetail(place));
}