TheM4hd1 / SwiftyInsta

Instagram Private API Swift

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Highlights media is empty

kagialikos opened this issue · comments

When I fetch highlight highlight.item(0) return that they are 6 media but highlight.item(0).media is empty

@watergr I checked it and I am not having any problems right now. Can you share your code block?

    self.handler.stories.highlightsBy(user: .primaryKey(11830955)) { (result) in
                   switch result {
                   case .success(let medias):
                       print(medias.items[1]) 
                      (print:  "mediaCount": SwiftyInsta.DynamicResponse.number(30))

                       print(medias.items[1].media)
                       (print: [])

                       print(medias.items[1].media.first)
                       (print: nil)

                   case .failure(let err):
                       print(err)
                   }
        }

Ok, I understand the problem. MediaCount is returns from directly Instagram, its not populated data count. Story based responses not always populated. This is how Instagram api works. Its not related SwiftyInsta.
You should call related methods.

In your case your code should be like this;

handler.stories.highlightsBy(user: .primaryKey(11830955)) { [weak self] (result) in
            switch result {
            case .success(let tray):
                let identity = tray.items.first?.identity.identifier

                guard let identity = identity else { return }
                
                self?.handler.stories.reelsMedia([identity]) { (result) in
                    switch result {
                    case .success(let dict):
                        print(dict)
                    case .failure(let error):
                        print(error.localizedDescription)
                    }
                }
            case .failure(let error):
                print(error)
            }
        }