Compare commits

...

1 Commits

View File

@ -59,18 +59,14 @@ public class PhotoAlbumModel {
}
/**
* Deletes a photo from the album by name.
* If the deleted photo is the current photo or the album is empty,
* the iterator is reset.
* Deletes a photo from the album by name (if it exists).
* Resets the iterator and notifies the listeners.
*
* @param name the name of the photo to delete
*/
public void deletePhoto(String name) {
Photo currentPhoto = iterator.current();
photos.removeIf(photo -> photo.name().equals(name));
if (photos.isEmpty() || (currentPhoto != null && currentPhoto.name().equals(name))) {
iterator = new PhotoIterator(photos);
}
iterator = new PhotoIterator(photos);
notifyListeners();
}