mirror of
git://jb55.com/damus
synced 2024-09-29 00:10:43 +00:00
Purple: Improve UX on Damus Purple renewals
This commit changes when the Damus Purple onboarding gets triggered. Now it only shows the onboarding if it is the first time they are purchasing Damus Purple for a Nostr account. If it is not the first they see the onboarding, they are directed to a sheet that displays their new account info (e.g. a renewal) However, if the website links to `damus:purple:welcome` links, the app will still show the onboarding. This will be addressed on the website-side by taking them to `damus:purple:landing` instead when it is a renewal. Testing --------- PASS Device: iPhone 13 mini (Physical device) iOS: 17.3.1 Damus: This commit damus-api: d3801376fa204433661be6de8b7974f12b0ad25f damus-website: 6bb425e324c318ca474417cbd2b2f8bb74f9505f Setup: - iOS configured to use a local test environment - Local damus-api server and local damus-website server setup and properly configured - Fresh db (i.e. Delete mdb files before starting) Coverage: 1. LN flow with switching to the app instead of clicking "continue". PASS a. Ensure that first purchase will result in onboarding being shown. PASS b. Ensure that second purchase will result in onboarding NOT being shown (User should be taken to the account info screen). PASS c. Restart app completely. Ensure third purchase will result in onboarding NOT being shown (only account info screen). PASS 2. LN flow with clicking continue (Since website changes are not ready, we will simulate them by manually generally appropriate "continue" URL QR codes) a. Note: Clear DB again before starting this portion, and completely restart app. b. Ensure that first purchase will result in onboarding being shown. PASS c. Ensure that second purchase (with continue URL manually hard-coded to `damus:purple:landing`) results in account info being shown with updated info. PASS d. Restart app completely and repeat test 2(c). PASS Signed-off-by: Daniel D’Aquino <daniel@daquino.me>
This commit is contained in:
parent
3569919eaf
commit
b49a5f4d29
@ -490,14 +490,18 @@ struct ContentView: View {
|
|||||||
// For extra assurance, run this after one second, to avoid race conditions if the app is also handling a damus purple welcome url.
|
// For extra assurance, run this after one second, to avoid race conditions if the app is also handling a damus purple welcome url.
|
||||||
DispatchQueue.main.asyncAfter(deadline: .now() + 1) {
|
DispatchQueue.main.asyncAfter(deadline: .now() + 1) {
|
||||||
Task {
|
Task {
|
||||||
// TODO: Improve UX for renewals (#2013)
|
|
||||||
let freshly_completed_checkout_ids = try? await damus_state.purple.check_status_of_checkouts_in_progress()
|
let freshly_completed_checkout_ids = try? await damus_state.purple.check_status_of_checkouts_in_progress()
|
||||||
let there_is_a_completed_checkout: Bool = (freshly_completed_checkout_ids?.count ?? 0) > 0
|
let there_is_a_completed_checkout: Bool = (freshly_completed_checkout_ids?.count ?? 0) > 0
|
||||||
let account_info = try await damus_state.purple.fetch_account(pubkey: self.keypair.pubkey)
|
let account_info = try await damus_state.purple.fetch_account(pubkey: self.keypair.pubkey)
|
||||||
if there_is_a_completed_checkout == true && account_info?.active == true {
|
if there_is_a_completed_checkout == true && account_info?.active == true {
|
||||||
|
if damus_state.purple.onboarding_status.user_has_never_seen_the_onboarding_before() {
|
||||||
// Show welcome sheet
|
// Show welcome sheet
|
||||||
self.active_sheet = .purple_onboarding
|
self.active_sheet = .purple_onboarding
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
self.active_sheet = .purple(DamusPurpleURL.init(is_staging: damus_state.purple.environment == .staging, variant: .landing))
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,6 +13,7 @@ class DamusPurple: StoreObserverDelegate {
|
|||||||
let keypair: Keypair
|
let keypair: Keypair
|
||||||
var storekit_manager: StoreKitManager
|
var storekit_manager: StoreKitManager
|
||||||
var checkout_ids_in_progress: Set<String> = []
|
var checkout_ids_in_progress: Set<String> = []
|
||||||
|
var onboarding_status: OnboardingStatus
|
||||||
|
|
||||||
@MainActor
|
@MainActor
|
||||||
var account_cache: [Pubkey: Account]
|
var account_cache: [Pubkey: Account]
|
||||||
@ -25,6 +26,16 @@ class DamusPurple: StoreObserverDelegate {
|
|||||||
self.account_cache = [:]
|
self.account_cache = [:]
|
||||||
self.account_uuid_cache = [:]
|
self.account_uuid_cache = [:]
|
||||||
self.storekit_manager = StoreKitManager.standard // Use singleton to avoid losing local purchase data
|
self.storekit_manager = StoreKitManager.standard // Use singleton to avoid losing local purchase data
|
||||||
|
self.onboarding_status = OnboardingStatus()
|
||||||
|
Task {
|
||||||
|
let account: Account? = try await self.fetch_account(pubkey: self.keypair.pubkey)
|
||||||
|
if account == nil {
|
||||||
|
self.onboarding_status.account_existed_at_the_start = false
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
self.onboarding_status.account_existed_at_the_start = true
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: Functions
|
// MARK: Functions
|
||||||
@ -449,4 +460,22 @@ extension DamusPurple {
|
|||||||
struct TranslationResult: Codable {
|
struct TranslationResult: Codable {
|
||||||
let text: String
|
let text: String
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct OnboardingStatus {
|
||||||
|
var account_existed_at_the_start: Bool? = nil
|
||||||
|
var onboarding_was_shown: Bool = false
|
||||||
|
|
||||||
|
init() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
init(account_active_at_the_start: Bool, onboarding_was_shown: Bool) {
|
||||||
|
self.account_existed_at_the_start = account_active_at_the_start
|
||||||
|
self.onboarding_was_shown = onboarding_was_shown
|
||||||
|
}
|
||||||
|
|
||||||
|
func user_has_never_seen_the_onboarding_before() -> Bool {
|
||||||
|
return onboarding_was_shown == false && account_existed_at_the_start == false
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -35,6 +35,8 @@ struct DamusPurpleNewUserOnboardingView: View {
|
|||||||
guard let account = try? await damus_state.purple.fetch_account(pubkey: damus_state.pubkey), account.active else {
|
guard let account = try? await damus_state.purple.fetch_account(pubkey: damus_state.pubkey), account.active else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
// Let's mark onboarding as "shown"
|
||||||
|
damus_state.purple.onboarding_status.onboarding_was_shown = true
|
||||||
// Let's notify other views across SwiftUI to update our user's Purple status.
|
// Let's notify other views across SwiftUI to update our user's Purple status.
|
||||||
notify(.purple_account_update(account))
|
notify(.purple_account_update(account))
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user