Skip to content

gallery duplicates image #819

@nursedayuksel

Description

@nursedayuksel

for example, i'm selecting three images, then i click next. when i go back the images i've pre-selected are still selected, so that's good. however when i click next again the three images get appended to my images array twice, so i end up having two of the same images. same if i go back and click next again, i'll have three of the same images. am i supposed to do something additional? i'm using an if to check if the array contains the same image, but i don't think that's doing anything, so maybe i'm checking the wrong thing?

  `picker.didFinishPicking { [unowned picker] items, cancelled in
        for item in items {
            switch item {
            case .photo(let photo):
                if !selectedImages.contains(photo.image) {
                    selectedImages.append(photo.image)
                }
            case .video(let video):
                if !videoURLs.contains(video.url) {
                    videoURLs.append(video.url)
                }
                print(video.url)
            }
            
            self.preselectedItems.append(item)
        }
        createPostViewModel.showPostPage = true
        
        if cancelled {
            picker.dismiss(animated: true, completion: nil)
            createPostViewModel.showPostPage = false
        }
    }
    return picker`

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions