mirror of
https://github.com/metabolist/metatext.git
synced 2024-11-27 18:41:01 +00:00
Refactoring
This commit is contained in:
parent
98ac456be6
commit
61d1a3619d
3 changed files with 16 additions and 22 deletions
|
@ -32,19 +32,15 @@ public extension MediaProcessingService {
|
|||
return Future<Data, Error> { promise in
|
||||
itemProvider.loadFileRepresentation(forTypeIdentifier: uniformType.identifier) { url, error in
|
||||
if let error = error {
|
||||
return promise(.failure(error))
|
||||
}
|
||||
|
||||
guard let url = url else { return promise(.failure(MediaProcessingError.fileURLNotFound)) }
|
||||
|
||||
promise(.failure(error))
|
||||
} else if let url = url {
|
||||
if uniformType.conforms(to: .image) {
|
||||
return promise(imageData(url: url, type: uniformType))
|
||||
promise(imageData(url: url, type: uniformType))
|
||||
} else {
|
||||
do {
|
||||
return try promise(.success(Data(contentsOf: url)))
|
||||
} catch {
|
||||
return promise(.failure(error))
|
||||
promise(Result { try Data(contentsOf: url) })
|
||||
}
|
||||
} else {
|
||||
promise(.failure(MediaProcessingError.fileURLNotFound))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -44,10 +44,10 @@ private extension UserNotificationService {
|
|||
Future<Bool, Error> { promise in
|
||||
userNotificationClient.requestAuthorization([.alert, .sound, .badge, .provisional]) { granted, error in
|
||||
if let error = error {
|
||||
return promise(.failure(error))
|
||||
promise(.failure(error))
|
||||
} else {
|
||||
promise(.success(granted))
|
||||
}
|
||||
|
||||
return promise(.success(granted))
|
||||
}
|
||||
}
|
||||
.eraseToAnyPublisher()
|
||||
|
|
|
@ -22,14 +22,12 @@ extension WebAuthSession {
|
|||
url: url,
|
||||
callbackURLScheme: callbackURLScheme) { oauthCallbackURL, error in
|
||||
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
|
||||
|
|
Loading…
Reference in a new issue