Skip to content

Commit

Permalink
fix: validation warning
Browse files Browse the repository at this point in the history
  • Loading branch information
phlpsong committed Feb 3, 2024
1 parent cf22a27 commit 91b216d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
13 changes: 9 additions & 4 deletions Easydict/Feature/Service/Gemini/GeminiService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,9 @@ public final class GeminiService: QueryService {

resultString += line
result.translatedResults = [resultString]
completion(result, nil)
await MainActor.run {
completion(result, nil)
}
}

} else {
Expand All @@ -118,7 +120,9 @@ public final class GeminiService: QueryService {
}

result.translatedResults = [resultString]
completion(result, nil)
await MainActor.run {
completion(result, nil)
}
}
} catch {
/**
Expand All @@ -132,8 +136,9 @@ public final class GeminiService: QueryService {
let errorString = String(describing: error)
let errorMessage = errorString.extract(withPattern: "message: \"([^\"]*)\"") ?? errorString
ezError?.errorDataMessage = errorMessage

completion(result, ezError)
await MainActor.run {
completion(result, ezError)
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,10 @@ struct ServiceConfigurationSecretSectionView<Content: View>: View {
func validate() {
viewModel.isValidating.toggle()
service.validate { _, error in
DispatchQueue.main.async {
viewModel.alertMessage = error == nil ? "service.configuration.validation_success" : "service.configuration.validation_fail"
print("\(service.serviceType()) validate \(error == nil ? "success" : "fail")!")
viewModel.isValidating.toggle()
viewModel.isAlertPresented.toggle()
}
viewModel.alertMessage = error == nil ? "service.configuration.validation_success" : "service.configuration.validation_fail"
print("\(service.serviceType()) validate \(error == nil ? "success" : "fail")!")
viewModel.isValidating.toggle()
viewModel.isAlertPresented.toggle()
}
}
}
Expand Down

0 comments on commit 91b216d

Please sign in to comment.