SwiftEntryKit
SwiftEntryKit copied to clipboard
Previously shown normal priority entry isn't displayed after dismissal of newly shown high priority entry
Describe the bug
A new entry with .high
priority is displayed while a previous .normal
was being displayed. After the dismissal of the new entry with .high
priority the previous entry with .normal
priority is not being displayed again.
To Reproduce Add two button in the UI and attach the two following action methods:
@IBAction func lowPriorityEntryButtonTapped(_ sender: UIButton) {
let view = UIView()
view.backgroundColor = .systemRed
view.translatesAutoresizingMaskIntoConstraints = false
NSLayoutConstraint.activate([
view.widthAnchor.constraint(equalToConstant: 200),
view.heightAnchor.constraint(equalToConstant: 200)
])
var attributes = EKAttributes.centerFloat
attributes.displayDuration = .infinity
attributes.entryInteraction = .dismiss
SwiftEntryKit.display(entry: view, using: attributes)
}
@IBAction func highPriorityEntryButtonTapped(_ sender: UIButton) {
let view = UIView()
view.backgroundColor = .systemBlue
view.translatesAutoresizingMaskIntoConstraints = false
NSLayoutConstraint.activate([
view.widthAnchor.constraint(equalToConstant: 200),
view.heightAnchor.constraint(equalToConstant: 200)
])
var attributes = EKAttributes.centerFloat
attributes.displayDuration = .infinity
attributes.entryInteraction = .dismiss
attributes.precedence = .override(priority: .high, dropEnqueuedEntries: false)
SwiftEntryKit.display(entry: view, using: attributes)
}
Expected behavior
Previously displayed entry with .normal
priority should be displayed again after the dismissal of the new entry.
iPhone (please complete the following information):
- Device: iPhone 7
- iOS Version: 14.0
- Xcode Version: 12.4
- Dependency Manager Version: CocoaPods 1.10.1
- SwiftEntryKit Release # 1.2.7
Additional context
As per the documentation here, enqueues entries remain in the queue and first entry in the queue should be shown again. But it doesn't. From the code in EKWindowProvider
it appears that the previous entry is not enqueued in the entryQueue
:
private func display(entryView: EKEntryView, using attributes: EKAttributes, presentInsideKeyWindow: Bool, rollbackWindow: SwiftEntryKit.RollbackWindow) {
switch entryView.attributes.precedence {
case .override(priority: _, dropEnqueuedEntries: let dropEnqueuedEntries):
if dropEnqueuedEntries {
entryQueue.removeAll()
}
// an else condition is expected here maybe(?) for not dropping the enqueues from the queue
show(entryView: entryView, presentInsideKeyWindow: presentInsideKeyWindow, rollbackWindow: rollbackWindow)
case .enqueue where isCurrentlyDisplaying():
entryQueue.enqueue(entry: .init(view: entryView, presentInsideKeyWindow: presentInsideKeyWindow, rollbackWindow: rollbackWindow))
case .enqueue:
show(entryView: entryView, presentInsideKeyWindow: presentInsideKeyWindow, rollbackWindow: rollbackWindow)
}
}
Any trick to solve this isssue?
@baveku nope, I didn't find any.