Skip to content
This repository was archived by the owner on Feb 24, 2025. It is now read-only.

Commit 926e38a

Browse files
committed
Improve refresh token
1 parent 1c61816 commit 926e38a

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

DuckDuckGo/Subscription/ViewModel/SubscriptionRestoreViewModel.swift

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ final class SubscriptionRestoreViewModel: ObservableObject {
7979
func onFirstAppear() async {
8080
Pixel.fire(pixel: .privacyProSettingsAddDevice)
8181
await setupTransactionObserver()
82+
await refreshToken()
8283
}
8384

8485
private func cleanUp() {
@@ -87,14 +88,14 @@ final class SubscriptionRestoreViewModel: ObservableObject {
8788
}
8889

8990
private func refreshToken() async {
90-
await AppStoreAccountManagementFlow.refreshAuthTokenIfNeeded(subscriptionAppGroup: Bundle.main.appGroup(bundle: .subs))
91+
if state.isAddingDevice {
92+
await AppStoreAccountManagementFlow.refreshAuthTokenIfNeeded(subscriptionAppGroup: Bundle.main.appGroup(bundle: .subs))
93+
}
9194
}
9295

9396
private func setupContent() async {
9497
if state.isAddingDevice {
9598

96-
await refreshToken()
97-
9899
DispatchQueue.main.async {
99100
self.state.isLoading = true
100101
}

0 commit comments

Comments
 (0)