@@ -9,13 +9,6 @@ private class IntroducingCustomNotificationAudioExperienceUpgradeViewController:
99
1010 var buttonAction : ( ( UIButton ) -> Void ) ?
1111
12- override func viewDidAppear( _ animated: Bool ) {
13- super. viewDidAppear ( animated)
14-
15- // Opt users in to the new default sound ("note") after they've seen the splash screen.
16- OWSSounds . setGlobalNotificationSound ( . note)
17- }
18-
1912 override func loadView( ) {
2013 self . view = UIView . container ( )
2114
@@ -51,8 +44,8 @@ private class IntroducingCustomNotificationAudioExperienceUpgradeViewController:
5144 let button = addButton ( title: buttonTitle) { _ in
5245 // dismiss the modally presented view controller, then proceed.
5346 self . experienceUpgradesPageViewController. dismiss ( animated: true ) {
54- guard let fromViewController = UIApplication . shared. frontmostViewController as? HomeViewController else {
55- owsFail ( " unexpected frontmostViewController: \( String ( describing : UIApplication . shared . frontmostViewController ) ) " )
47+ guard let fromViewController = UIApplication . shared. frontmostViewController else {
48+ owsFail ( " frontmostViewController was unexectedly nil " )
5649 return
5750 }
5851
@@ -497,12 +490,15 @@ class ExperienceUpgradesPageViewController: OWSViewController, UIPageViewControl
497490
498491 let pageViewController : UIPageViewController
499492
493+ let editingDBConnection : YapDatabaseConnection
494+
500495 // MARK: - Initializers
501496
502497 required init ( experienceUpgrades: [ ExperienceUpgrade ] ) {
503498 self . experienceUpgrades = experienceUpgrades
504499
505500 setPageControlAppearance ( )
501+ self . editingDBConnection = OWSPrimaryStorage . shared ( ) . newDatabaseConnection ( )
506502 self . pageViewController = UIPageViewController ( transitionStyle: . scroll, navigationOrientation: . horizontal, options: nil )
507503 super. init ( nibName: nil , bundle: nil )
508504 self . pageViewController. dataSource = self
@@ -512,12 +508,7 @@ class ExperienceUpgradesPageViewController: OWSViewController, UIPageViewControl
512508
513509 @available ( * , unavailable, message: " unavailable, use initWithExperienceUpgrade instead " )
514510 required init ? ( coder aDecoder: NSCoder ) {
515- assert ( false )
516- // This should never happen, but so as not to explode we give some bogus data
517- self . experienceUpgrades = [ ExperienceUpgrade ( ) ]
518- self . pageViewController = UIPageViewController ( transitionStyle: . scroll, navigationOrientation: . horizontal, options: nil )
519- super. init ( coder: aDecoder)
520- self . pageViewController. dataSource = self
511+ fatalError ( " unimplemented " )
521512 }
522513
523514 // MARK: - View lifecycle
@@ -686,6 +677,16 @@ class ExperienceUpgradesPageViewController: OWSViewController, UIPageViewControl
686677 allViewControllers. append ( viewController)
687678 }
688679
680+ override func dismiss( animated flag: Bool , completion: ( ( ) -> Void ) ? = nil ) {
681+ // Blocking write before dismiss, to be sure they're marked as complete
682+ // before HomeView.didAppear is re-fired.
683+ self . editingDBConnection. readWrite { transaction in
684+ Logger . info ( " \( self . logTag) marking all upgrades as seen. " )
685+ ExperienceUpgradeFinder . shared. markAllAsSeen ( transaction: transaction)
686+ }
687+ super. dismiss ( animated: flag, completion: completion)
688+ }
689+
689690 func didTapDismissButton( sender: UIButton ) {
690691 Logger . debug ( " \( TAG) in \( #function) " )
691692 self . dismiss ( animated: true )
0 commit comments