2022-10-05 09:44:25 +02:00
|
|
|
// Copyright © 2022 Rangeproof Pty Ltd. All rights reserved.
|
|
|
|
|
|
|
|
import Foundation
|
2022-12-06 00:13:04 +01:00
|
|
|
import Combine
|
2022-10-05 09:44:25 +02:00
|
|
|
import GRDB
|
|
|
|
import SessionUtilitiesKit
|
|
|
|
|
|
|
|
class SynchronousStorage: Storage {
|
2022-12-06 00:13:04 +01:00
|
|
|
override func writePublisher<T>(updates: @escaping (Database) throws -> T) -> AnyPublisher<T, Error> {
|
|
|
|
guard let result: T = super.write(updates: updates) else {
|
|
|
|
return Fail(error: StorageError.generic)
|
|
|
|
.eraseToAnyPublisher()
|
2022-10-05 09:44:25 +02:00
|
|
|
}
|
2022-12-06 00:13:04 +01:00
|
|
|
|
|
|
|
return Just(result)
|
|
|
|
.setFailureType(to: Error.self)
|
|
|
|
.eraseToAnyPublisher()
|
2022-10-05 09:44:25 +02:00
|
|
|
}
|
|
|
|
}
|