Skip to content

Commit

Permalink
unregister connected to sample app
Browse files Browse the repository at this point in the history
  • Loading branch information
flypaper0 committed Oct 16, 2023
1 parent 1eb68e5 commit 2a5f089
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
import Foundation
import WalletConnectNotify

final class SettingsInteractor {

func notifyUnregister(account: Account) async throws {
try await Notify.instance.unregister(account: account)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,12 @@ final class SettingsPresenter: ObservableObject {
return deviceToken
}

func logoutPressed() {
func logoutPressed() async throws {
guard let account = accountStorage.importAccount?.account else { return }
try await interactor.notifyUnregister(account: account)
accountStorage.importAccount = nil
UserDefaults.standard.set(nil, forKey: "deviceToken")
router.presentWelcome()
await router.presentWelcome()
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ final class SettingsRouter {
self.app = app
}

func presentWelcome() {
@MainActor func presentWelcome() async {
WelcomeModule.create(app: app).present()
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import SwiftUI
import AsyncButton

struct SettingsView: View {

Expand All @@ -19,8 +20,8 @@ struct SettingsView: View {
}

Section {
Button {
viewModel.logoutPressed()
AsyncButton {
try await viewModel.logoutPressed()
} label: {
Text("Log out")
.foregroundColor(.red)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public class NotifyClient {
subscriptionWatcher.start()
}

func unregister(account: Account) async throws {
public func unregister(account: Account) async throws {
try await identityService.unregister(account: account)
try await resubscribeService.unsubscribe(account: account)

Expand Down

0 comments on commit 2a5f089

Please sign in to comment.