hyperoslo / Imaginary

:unicorn: Remote images, as easy as one, two, three.
https://www.hyper.no
Other
614 stars 63 forks source link

Completion blocks not being called #81

Closed goto10 closed 4 years ago

goto10 commented 6 years ago

I have tested it with the .setImage function and with the code below and in both cases the completion block is never called.

Fetching is printed as expected but I never get to got it. In the case of the .setImage the imageView's image is being set but the completion block is never called there either.

            if let photo = project?.photos[indexPath.row],
                let photoURL = URL(string: "\(project?.smallResBaseURL ?? "")\(photo.filename)") {
                print("FETCHING")
                let fetcher = ImageFetcher(downloader: Option().downloaderMaker(), storage: Imaginary.Configuration.imageStorage)
                fetcher.fetch(url: photoURL, completion: { (result) in
                    print("** GOT IT **")
                    switch result {
                    case .value(let image):
                        if photo.ratio == 0 {
                            let ratio = Double(image.size.height / image.size.width)
                            photo.updateRatio(ratio)
                            collectionView.collectionViewLayout.invalidateLayout()
                        }
                    case .error(let error):
                        print(error.localizedDescription)
                    }
                })