[Refactor] Use firstly and tweak formatting

pull/4409/head
Hwee-Boon Yar 3 years ago
parent c92b0dd2c5
commit 001da345f9
  1. 10
      AlphaWallet/Core/Helpers/BlockieGenerator.swift

@ -110,10 +110,12 @@ class BlockiesGenerator {
return firstly {
promise
}.then { url -> Promise<BlockiesImage> in
return Self.decodeEip155URL(url: url).then { value -> Promise<BlockiesImage> in
Self.fetchOpenSeaAssetImageUrl(from: value).then { url -> Promise<BlockiesImage> in
return Self.fetchEnsAvatar(request: URLRequest(url: url), queue: .main)
}
return firstly {
Self.decodeEip155URL(url: url)
}.then { value -> Promise<URL> in
Self.fetchOpenSeaAssetImageUrl(from: value)
}.then { url -> Promise<BlockiesImage> in
Self.fetchEnsAvatar(request: URLRequest(url: url), queue: .main)
}.recover { _ -> Promise<BlockiesImage> in
guard let url = URL(string: url) else { return .init(error: AnyError.blockieCreateFailure) }
return Self.fetchEnsAvatar(request: URLRequest(url: url), queue: .main)

Loading…
Cancel
Save