Skip to content

Commit 27a3248

Browse files
authored
Merge pull request #7543 from woocommerce/issue/7540-dismiss-onboarding-notice-after-multiple-steps
[Mobile Payments] Display maximum one notice at a time
2 parents 8f835ad + 0ee8622 commit 27a3248

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

RELEASE-NOTES.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
10.1
44
-----
5-
5+
- [*] In-Person Payments: The onboarding notice on the In-Person Payments menu is correctly dismissed after multiple prompts are shown. [https://github.com/woocommerce/woocommerce-ios/pull/7543]
66

77
10.0
88
-----

WooCommerce/Classes/Tools/Notices/PermanentNotice/PermanentNoticePresenter.swift

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,13 @@ final class PermanentNoticePresenter {
1717
private var hostingController: UIHostingController<PermanentNoticeView>?
1818

1919
/// Presents the given notice into the passed view controller with an animation
20+
/// This will ignore any calls to present if a notice is already displayed
2021
///
2122
func presentNotice(notice: PermanentNotice, from viewController: UIViewController) {
23+
guard hostingController == nil else {
24+
return
25+
}
26+
2227
let permanentNoticeView = PermanentNoticeView(notice: notice)
2328
let newHostingController = ConstraintsUpdatingHostingController(rootView: permanentNoticeView)
2429

@@ -76,12 +81,14 @@ private extension PermanentNoticePresenter {
7681

7782
UIView.animate(withDuration: Animations.appearanceDuration,
7883
delay: 0,
79-
options: .transitionFlipFromLeft, animations: {
84+
options: .transitionFlipFromLeft,
85+
animations: {
8086
hostingController.view.alpha = 0
81-
}) { _ in
82-
hostingController.willMove(toParent: nil)
83-
hostingController.view.removeFromSuperview()
84-
}
87+
}) { [weak self] _ in
88+
hostingController.willMove(toParent: nil)
89+
hostingController.view.removeFromSuperview()
90+
self?.hostingController = nil
91+
}
8592
}
8693
}
8794

0 commit comments

Comments
 (0)