mirror of
https://github.com/Dimillian/IceCubesApp.git
synced 2024-11-25 17:51:01 +00:00
Completely clear duplicated push notifications issue
This commit is contained in:
parent
7ac8333912
commit
418e9545ba
2 changed files with 10 additions and 5 deletions
|
@ -92,7 +92,7 @@ struct PushNotificationsView: View {
|
|||
Button("settings.push.duplicate.button.fix") {
|
||||
Task {
|
||||
await subscription.deleteSubscription()
|
||||
await subscription.updateSubscription(forceCreate: true)
|
||||
await subscription.updateSubscription()
|
||||
}
|
||||
}
|
||||
} header: {
|
||||
|
@ -113,7 +113,7 @@ struct PushNotificationsView: View {
|
|||
|
||||
private func updateSubscription() {
|
||||
Task {
|
||||
await subscription.updateSubscription(forceCreate: true)
|
||||
await subscription.updateSubscription()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -64,7 +64,12 @@ public class PushNotificationsService: ObservableObject {
|
|||
await withTaskGroup(of: Void.self, body: { group in
|
||||
group.addTask {
|
||||
await subscription.fetchSubscription()
|
||||
await subscription.updateSubscription(forceCreate: forceCreate)
|
||||
if await subscription.subscription != nil && !forceCreate {
|
||||
await subscription.deleteSubscription()
|
||||
await subscription.updateSubscription()
|
||||
} else if forceCreate {
|
||||
await subscription.updateSubscription()
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
@ -159,8 +164,8 @@ public class PushNotificationSubscriptionSettings: ObservableObject {
|
|||
}
|
||||
}
|
||||
|
||||
public func updateSubscription(forceCreate: Bool) async {
|
||||
guard let pushToken = pushToken, subscription != nil || forceCreate else { return }
|
||||
public func updateSubscription() async {
|
||||
guard let pushToken = pushToken else { return }
|
||||
let client = Client(server: account.server, oauthToken: account.token)
|
||||
do {
|
||||
var listenerURL = PushNotificationsService.Constants.endpoint
|
||||
|
|
Loading…
Reference in a new issue