Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

APPLE: fix app stuck in daemon installation state #1986

Draft
wants to merge 1 commit into
base: release/2025.1-mirabelle
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions nym-vpn-apple/Home/Sources/Home/HomeViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -169,9 +169,6 @@ public extension HomeViewModel {
updateConnectButtonState(with: .connect)
return
}

updateStatusInfoState(with: .unknown)
updateConnectButtonState(with: .connect)
#endif
guard credentialsManager.isValidCredentialImported
else {
Expand Down Expand Up @@ -368,6 +365,9 @@ private extension HomeViewModel {
case .installing:
self?.updateStatusInfoState(with: .installingDaemon)
self?.updateConnectButtonState(with: .installingDaemon)
case .installed:
self?.updateStatusInfoState(with: .unknown)
self?.updateConnectButtonState(with: .connect)
case .unknown, .running:
break
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public final class CredentialsManager {

try storeAccountMnemonicRaw(mnemonic: credential, path: dataFolderURL.path())
#elseif os(macOS)
try? await helperInstallManager.installIfNeeded()
try await helperInstallManager.installIfNeeded()
try await grpcManager.storeAccount(with: credential)
#endif
checkCredentialImport()
Expand Down Expand Up @@ -115,7 +115,8 @@ private extension CredentialsManager {
.store(in: &cancellables)

helperInstallManager.$daemonState.sink { [weak self] state in
guard state == .running else { return }
print("🚜 cred man: \(state)")
guard state == .running || state == .installed else { return }
self?.checkCredentialImport()
}
.store(in: &cancellables)
Expand All @@ -126,6 +127,7 @@ private extension CredentialsManager {
private extension CredentialsManager {
func checkCredentialImport() {
Task(priority: .background) {
print("🚜 check cred import")
do {
let isImported: Bool
#if os(iOS)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,21 +28,23 @@ extension GRPCManager {
logger.log(level: .info, "Forgetting credentials")

return try await withCheckedThrowingContinuation { continuation in
let call = client.forgetAccount(Google_Protobuf_Empty())
Task {
let call = client.forgetAccount(Google_Protobuf_Empty())

call.response.whenComplete { result in
switch result {
case .success(let response):
if response.hasError {
continuation.resume(throwing: GeneralNymError.library(message: response.error.message))
} else {
continuation.resume()
call.response.whenComplete { result in
switch result {
case .success(let response):
if response.hasError {
continuation.resume(throwing: GeneralNymError.library(message: response.error.message))
} else {
continuation.resume()
}
case .failure(let error):
continuation.resume(
throwing:
GeneralNymError.library(message: error.localizedDescription)
)
}
case .failure(let error):
continuation.resume(
throwing:
GeneralNymError.library(message: error.localizedDescription)
)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
public enum DaemonState {
case running
case installing
case installed
case unknown
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ extension HelperInstallManager {
daemonState = .unknown
throw error
}
try? await Task.sleep(for: .seconds(10))
try await Task.sleep(for: .seconds(10))
daemonState = .installed
}
}