Skip to content

Commit

Permalink
Fix agent startup (#2107)
Browse files Browse the repository at this point in the history
Task/Issue URL: https://app.asana.com/0/1203581873609357/1206412688037751/f

**Description**:
* Prevents the background agent from starting on waitlist users that did
not start the DBP process
* Disable the agent if the user doesn't have profile data
  • Loading branch information
Bunn authored Jan 23, 2024
1 parent abf213a commit 3d96adc
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion DuckDuckGo/DBP/DataBrokerProtectionAppEvents.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,17 @@ struct DataBrokerProtectionAppEvents {

Task {
try? await DataBrokerProtectionWaitlist().redeemDataBrokerProtectionInviteCodeIfAvailable()

// If we don't have profileQueries it means there's no user profile saved in our DB
// In this case, let's disable the agent and delete any left-over data because there's nothing for it to do
let profileQueries = await DataBrokerProtectionManager.shared.dataManager.fetchBrokerProfileQueryData(ignoresCache: true)
if profileQueries.count > 0 {
restartBackgroundAgent(loginItemsManager: loginItemsManager)
} else {
featureVisibility.disableAndDeleteForWaitlistUsers()
}
}

restartBackgroundAgent(loginItemsManager: loginItemsManager)
}

func applicationDidBecomeActive() {
Expand Down

0 comments on commit 3d96adc

Please sign in to comment.