diff --git a/Save/Main/MainViewController.swift b/Save/Main/MainViewController.swift index 8f6a549..2810149 100644 --- a/Save/Main/MainViewController.swift +++ b/Save/Main/MainViewController.swift @@ -236,6 +236,20 @@ class MainViewController: UIViewController, UICollectionViewDelegateFlowLayout, updateManageBt() } + override func prepare(for segue: UIStoryboardSegue, sender: Any?) { + super.prepare(for: segue, sender: sender) + + // Make sure, the `SpaceWizardViewController` calls us back on success, + // so we can make the user select/create a folder right after + // connecting the server. + if segue.identifier == Self.segueConnectSpace, + let navC = segue.destination as? UINavigationController, + let vc = navC.viewControllers.first as? SpaceWizardViewController + { + vc.delegate = self + } + } + /** Workaround for the filtered view, which potentially got reset by the share extension's `Db#setup` call. diff --git a/Save/Space/DropboxWizardViewController.swift b/Save/Space/DropboxWizardViewController.swift index 203cc84..65d6a8f 100644 --- a/Save/Space/DropboxWizardViewController.swift +++ b/Save/Space/DropboxWizardViewController.swift @@ -11,7 +11,7 @@ import SwiftyDropbox class DropboxWizardViewController: BaseViewController, WizardDelegatable { - var delegate: WizardDelegate? + weak var delegate: WizardDelegate? @IBOutlet weak var iconIv: UIImageView! { didSet { diff --git a/Save/Space/GdriveWizardViewController.swift b/Save/Space/GdriveWizardViewController.swift index eae8219..f589571 100644 --- a/Save/Space/GdriveWizardViewController.swift +++ b/Save/Space/GdriveWizardViewController.swift @@ -13,7 +13,7 @@ import CleanInsightsSDK class GdriveWizardViewController: BaseViewController, WizardDelegatable { - var delegate: WizardDelegate? + weak var delegate: WizardDelegate? @IBOutlet weak var iconIv: UIImageView! { didSet { diff --git a/Save/Space/SpaceSuccessViewController.swift b/Save/Space/SpaceSuccessViewController.swift index 110f67e..f018e0a 100644 --- a/Save/Space/SpaceSuccessViewController.swift +++ b/Save/Space/SpaceSuccessViewController.swift @@ -8,7 +8,9 @@ import UIKit -class SpaceSuccessViewController: BaseViewController { +class SpaceSuccessViewController: BaseViewController, WizardDelegatable { + + weak var delegate: WizardDelegate? var spaceName = "" @@ -32,6 +34,6 @@ class SpaceSuccessViewController: BaseViewController { } @IBAction func done() { - dismiss(animated: true) + delegate?.dismiss(success: true) } } diff --git a/Save/Space/SpaceWizardViewController.swift b/Save/Space/SpaceWizardViewController.swift index 6c89300..7bc8286 100644 --- a/Save/Space/SpaceWizardViewController.swift +++ b/Save/Space/SpaceWizardViewController.swift @@ -13,6 +13,8 @@ protocol WizardDelegate: AnyObject { func back() func next(_ vc: UIViewController, pos: Int) + + func dismiss(success: Bool) } protocol WizardDelegatable: AnyObject { @@ -22,6 +24,8 @@ protocol WizardDelegatable: AnyObject { class SpaceWizardViewController: BasePageViewController, WizardDelegate { + weak var delegate: MainViewController? + private lazy var viewControllers: [UIViewController] = [UIStoryboard.main.instantiate(SpaceTypeViewController.self)] override func viewDidLoad() { @@ -72,6 +76,14 @@ class SpaceWizardViewController: BasePageViewController, WizardDelegate { pageControl.currentPage = page } + func dismiss(success: Bool) { + dismiss(animated: true) + + if success { + delegate?.addFolder() + } + } + // MARK: UIPageViewControllerDataSource diff --git a/Save/Space/WebDavWizardViewController.swift b/Save/Space/WebDavWizardViewController.swift index dfd88b1..7d6d10a 100644 --- a/Save/Space/WebDavWizardViewController.swift +++ b/Save/Space/WebDavWizardViewController.swift @@ -12,7 +12,7 @@ import FavIcon class WebDavWizardViewController: BaseViewController, WizardDelegatable, TextBoxDelegate { - var delegate: WizardDelegate? + weak var delegate: WizardDelegate? @IBOutlet weak var iconIv: UIImageView!