mirror of
https://github.com/oxen-io/session-ios.git
synced 2023-12-13 21:30:14 +01:00
eeccfb47d5
Fixed some broken file paths Fixed a couple of bugs with closed groups Fixed a few migration issues Fixed a bug with the ProfilePictureView in open groups (was including the open parenthesis in the initials) Migrated the Id Blinding changes to work with GRDB Migrated the call logic to work with GRDB Updated the code to work the with hard fork changes
30 lines
1.1 KiB
Swift
30 lines
1.1 KiB
Swift
// Copyright © 2022 Rangeproof Pty Ltd. All rights reserved.
|
|
|
|
import Foundation
|
|
import PromiseKit
|
|
import SessionSnodeKit
|
|
import SessionUtilitiesKit
|
|
|
|
extension Promise where T == Data {
|
|
func decoded<R: Decodable>(as type: R.Type, on queue: DispatchQueue? = nil, using dependencies: Dependencies = Dependencies()) -> Promise<R> {
|
|
self.map(on: queue) { data -> R in
|
|
try data.decoded(as: type, using: dependencies)
|
|
}
|
|
}
|
|
}
|
|
|
|
extension Promise where T == (OnionRequestResponseInfoType, Data?) {
|
|
func decoded<R: Decodable>(as type: R.Type, on queue: DispatchQueue? = nil, using dependencies: Dependencies = Dependencies()) -> Promise<(OnionRequestResponseInfoType, R)> {
|
|
self.map(on: queue) { responseInfo, maybeData -> (OnionRequestResponseInfoType, R) in
|
|
guard let data: Data = maybeData else { throw HTTP.Error.parsingFailed }
|
|
|
|
do {
|
|
return (responseInfo, try data.decoded(as: type, using: dependencies))
|
|
}
|
|
catch {
|
|
throw HTTP.Error.parsingFailed
|
|
}
|
|
}
|
|
}
|
|
}
|