Skip to content

Commit

Permalink
Merge branch 'main' into fcappelli/subscription_refactoring_2
Browse files Browse the repository at this point in the history
  • Loading branch information
federicocappelli committed May 22, 2024
2 parents 6769682 + 1b90ac6 commit 17dfc80
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 17 deletions.
33 changes: 22 additions & 11 deletions DuckDuckGo/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,7 @@ import WebKit
}
}

// swiftlint:disable:next function_body_length
func applicationDidBecomeActive(_ application: UIApplication) {
guard !testing else { return }

Expand Down Expand Up @@ -476,7 +477,10 @@ import WebKit
checkWaitlists()
syncService.scheduler.notifyAppLifecycleEvent()
fireFailedCompilationsPixelIfNeeded()
refreshShortcuts()

Task {
await refreshShortcuts()
}

#if NETWORK_PROTECTION
widgetRefreshModel.refreshVPNWidget()
Expand Down Expand Up @@ -549,7 +553,9 @@ import WebKit
}

func applicationWillResignActive(_ application: UIApplication) {
refreshShortcuts()
Task {
await refreshShortcuts()
}
}

private func fireAppLaunchPixel() {
Expand Down Expand Up @@ -879,22 +885,27 @@ import WebKit
return window?.rootViewController as? MainViewController
}

func refreshShortcuts() {
@MainActor
func refreshShortcuts() async {
#if NETWORK_PROTECTION
guard AppDependencyProvider.shared.vpnFeatureVisibility.shouldShowVPNShortcut() else {
UIApplication.shared.shortcutItems = nil
return
}

let items = [
UIApplicationShortcutItem(type: ShortcutKey.openVPNSettings,
localizedTitle: UserText.netPOpenVPNQuickAction,
localizedSubtitle: nil,
icon: UIApplicationShortcutIcon(templateImageName: "VPN-16"),
userInfo: nil)
]
if case .success(true) = await AccountManager().hasEntitlement(for: .networkProtection, cachePolicy: .returnCacheDataDontLoad) {

Check failure on line 896 in DuckDuckGo/AppDelegate.swift

View workflow job for this annotation

GitHub Actions / Make Release Build

missing arguments for parameters 'accessTokenStorage', 'entitlementsCache', 'subscriptionService', 'authService' in call

Check failure on line 896 in DuckDuckGo/AppDelegate.swift

View workflow job for this annotation

GitHub Actions / Unit Tests

missing arguments for parameters 'accessTokenStorage', 'entitlementsCache', 'subscriptionService', 'authService' in call
let items = [
UIApplicationShortcutItem(type: ShortcutKey.openVPNSettings,
localizedTitle: UserText.netPOpenVPNQuickAction,
localizedSubtitle: nil,
icon: UIApplicationShortcutIcon(templateImageName: "VPN-16"),
userInfo: nil)
]

UIApplication.shared.shortcutItems = items
UIApplication.shared.shortcutItems = items
} else {
UIApplication.shared.shortcutItems = nil
}
#endif
}

Expand Down
2 changes: 1 addition & 1 deletion DuckDuckGo/Autoconsent/autoconsent-bundle.js

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@
"rollup-plugin-terser": "^7.0.2"
},
"dependencies": {
"@duckduckgo/autoconsent": "^10.6.1"
"@duckduckgo/autoconsent": "^10.8.0"
}
}

0 comments on commit 17dfc80

Please sign in to comment.