Skip to content

Commit

Permalink
[NT-1055] LandingPage deeplink handling bug fix (#1146)
Browse files Browse the repository at this point in the history
  • Loading branch information
Scollaco committed Apr 8, 2020
1 parent 70cfc0b commit 3506287
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 4 deletions.
9 changes: 5 additions & 4 deletions Kickstarter-iOS/ViewModels/AppDelegateViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -340,8 +340,13 @@ public final class AppDelegateViewModel: AppDelegateViewModelType, AppDelegateVi
)
.skipNil()

self.goToLandingPage = self.applicationLaunchOptionsProperty.signal.ignoreValues()
.takeWhen(self.didUpdateOptimizelyClientProperty.signal.ignoreValues())
.filter(shouldGoToLandingPage)

let deepLink = deeplinkActivated
.filter { _ in shouldGoToLandingPage() == false }
.take(until: self.goToLandingPage)

self.findRedirectUrl = deepLinkUrl
.filter { Navigation.match($0) == .emailClick }
Expand Down Expand Up @@ -378,10 +383,6 @@ public final class AppDelegateViewModel: AppDelegateViewModelType, AppDelegateVi
.filter { $0 == .tab(.search) }
.ignoreValues()

self.goToLandingPage = self.applicationLaunchOptionsProperty.signal.ignoreValues()
.takeWhen(self.didUpdateOptimizelyClientProperty.signal.ignoreValues())
.filter(shouldGoToLandingPage)

self.goToLogin = deepLink
.filter { $0 == .tab(.login) }
.ignoreValues()
Expand Down
27 changes: 27 additions & 0 deletions Kickstarter-iOS/ViewModels/AppDelegateViewModelTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2348,6 +2348,33 @@ final class AppDelegateViewModelTests: TestCase {
self.goToLandingPage.assertDidNotEmitValue()
}
}

func testDeeplink_DoesNotActivateIf_GoToLandingPageEmits() {
let optimizelyClient = MockOptimizelyClient()
|> \.experiments .~
[OptimizelyExperiment.Key.nativeOnboarding.rawValue: OptimizelyExperiment.Variant.variant1.rawValue]

let userDefaults = MockKeyValueStore()
|> \.hasSeenLandingPage .~ false

withEnvironment(currentUser: nil, optimizelyClient: optimizelyClient, userDefaults: userDefaults) {
self.goToLandingPage.assertDidNotEmitValue()

self.vm.inputs.applicationDidFinishLaunching(application: UIApplication.shared, launchOptions: nil)
self.vm.inputs.didUpdateOptimizelyClient(MockOptimizelyClient())

_ = self.vm.inputs.applicationOpenUrl(
application: UIApplication.shared,
url: URL(
string: "https://www.kickstarter.com/projects/chelsea-punk/chelsea-punk-band-the-final-album"
)!,
options: [:]
)

self.presentViewController.assertDidNotEmitValue()
self.goToLandingPage.assertValueCount(1)
}
}
}

private func qualtricsProps() -> [String: String] {
Expand Down

0 comments on commit 3506287

Please sign in to comment.