Refactoring
This commit is contained in:
parent
98ac456be6
commit
61d1a3619d
|
@ -32,19 +32,15 @@ public extension MediaProcessingService {
|
||||||
return Future<Data, Error> { promise in
|
return Future<Data, Error> { promise in
|
||||||
itemProvider.loadFileRepresentation(forTypeIdentifier: uniformType.identifier) { url, error in
|
itemProvider.loadFileRepresentation(forTypeIdentifier: uniformType.identifier) { url, error in
|
||||||
if let error = error {
|
if let error = error {
|
||||||
return promise(.failure(error))
|
promise(.failure(error))
|
||||||
}
|
} else if let url = url {
|
||||||
|
if uniformType.conforms(to: .image) {
|
||||||
guard let url = url else { return promise(.failure(MediaProcessingError.fileURLNotFound)) }
|
promise(imageData(url: url, type: uniformType))
|
||||||
|
} else {
|
||||||
if uniformType.conforms(to: .image) {
|
promise(Result { try Data(contentsOf: url) })
|
||||||
return promise(imageData(url: url, type: uniformType))
|
|
||||||
} else {
|
|
||||||
do {
|
|
||||||
return try promise(.success(Data(contentsOf: url)))
|
|
||||||
} catch {
|
|
||||||
return promise(.failure(error))
|
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
promise(.failure(MediaProcessingError.fileURLNotFound))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,10 +44,10 @@ private extension UserNotificationService {
|
||||||
Future<Bool, Error> { promise in
|
Future<Bool, Error> { promise in
|
||||||
userNotificationClient.requestAuthorization([.alert, .sound, .badge, .provisional]) { granted, error in
|
userNotificationClient.requestAuthorization([.alert, .sound, .badge, .provisional]) { granted, error in
|
||||||
if let error = error {
|
if let error = error {
|
||||||
return promise(.failure(error))
|
promise(.failure(error))
|
||||||
|
} else {
|
||||||
|
promise(.success(granted))
|
||||||
}
|
}
|
||||||
|
|
||||||
return promise(.success(granted))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.eraseToAnyPublisher()
|
.eraseToAnyPublisher()
|
||||||
|
|
|
@ -22,14 +22,12 @@ extension WebAuthSession {
|
||||||
url: url,
|
url: url,
|
||||||
callbackURLScheme: callbackURLScheme) { oauthCallbackURL, error in
|
callbackURLScheme: callbackURLScheme) { oauthCallbackURL, error in
|
||||||
if let error = error {
|
if let error = error {
|
||||||
return promise(.failure(error))
|
promise(.failure(error))
|
||||||
|
} else if let oauthCallbackURL = oauthCallbackURL {
|
||||||
|
promise(.success(oauthCallbackURL))
|
||||||
|
} else {
|
||||||
|
promise(.failure(URLError(.unknown)))
|
||||||
}
|
}
|
||||||
|
|
||||||
guard let oauthCallbackURL = oauthCallbackURL else {
|
|
||||||
return promise(.failure(URLError(.unknown)))
|
|
||||||
}
|
|
||||||
|
|
||||||
return promise(.success(oauthCallbackURL))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
webAuthSession.presentationContextProvider = presentationContextProvider
|
webAuthSession.presentationContextProvider = presentationContextProvider
|
||||||
|
|
Loading…
Reference in New Issue