mirror of
https://github.com/Dimillian/IceCubesApp.git
synced 2024-12-18 13:16:49 +00:00
Primitive validation of domain before trying to connect (#287)
* Primitive validation of domain before trying to connect Every domain needs at least one "dot" and can't end with a "dot." Don't try connecting unless/until these are both true. * Correctly reset instance when invalid Co-authored-by: Thomas Ricouard <ricouard77@gmail.com>
This commit is contained in:
parent
fe1d886b62
commit
3658c4f829
1 changed files with 10 additions and 4 deletions
|
@ -87,11 +87,17 @@ struct AddAccountView: View {
|
||||||
let client = Client(server: newValue)
|
let client = Client(server: newValue)
|
||||||
Task {
|
Task {
|
||||||
do {
|
do {
|
||||||
let instance: Instance = try await client.get(endpoint: Instances.instance)
|
// bare bones preflight for domain validity
|
||||||
withAnimation {
|
if client.server.contains(".") && client.server.last != "." {
|
||||||
self.instance = instance
|
let instance: Instance = try await client.get(endpoint: Instances.instance)
|
||||||
|
withAnimation {
|
||||||
|
self.instance = instance
|
||||||
|
}
|
||||||
|
instanceFetchError = nil
|
||||||
|
} else {
|
||||||
|
instance = nil
|
||||||
|
instanceFetchError = nil
|
||||||
}
|
}
|
||||||
instanceFetchError = nil
|
|
||||||
} catch _ as DecodingError {
|
} catch _ as DecodingError {
|
||||||
instance = nil
|
instance = nil
|
||||||
instanceFetchError = "account.add.error.instance-not-supported"
|
instanceFetchError = "account.add.error.instance-not-supported"
|
||||||
|
|
Loading…
Reference in a new issue