Skip to content

Loaf stop showing after dismiss #22

@talzahrani

Description

@talzahrani

I notice my App some time Loaf stop showing, I made some debug inside the library and I noticed the issue because of this condition "isPresenting == false".

fileprivate func presentIfPossible() {

        guard isPresenting == false, let loaf = queue.dequeue(), let sender = loaf.sender else { return }
        isPresenting = true
        let loafVC = LoafViewController(loaf)
        loafVC.delegate = self
        sender.presentToast(loafVC)
 }

in my case, I fire dismiss in my controller view while Loaf is still showing will dismis Loaf and will not fire blow code especially "self?.delegate?.loafDidDismiss()"

DispatchQueue.main.asyncAfter(deadline: .now() + loaf.duration.length, execute: {
        self.dismiss(animated: true) { [weak self] in
               self?.delegate?.loafDidDismiss()
               self?.loaf.completionHandler?(.timedOut)
          }
 })

I fixed this by add override dismiss func in Loaf ViewController

override func dismiss(animated flag: Bool, completion: (() -> Void)? = nil) {
        super.dismiss(animated: flag, completion: completion)
         self.delegate?.loafDidDismiss()
 } 

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions