mirror of
https://github.com/metabolist/metatext.git
synced 2024-11-22 16:21:00 +00:00
Refactoring
This commit is contained in:
parent
758c375547
commit
9507343511
2 changed files with 3 additions and 10 deletions
|
@ -218,17 +218,12 @@ public extension ContentDatabase {
|
||||||
.eraseToAnyPublisher()
|
.eraseToAnyPublisher()
|
||||||
}
|
}
|
||||||
|
|
||||||
func accountObservation(id: String) -> AnyPublisher<Account?, Error> {
|
func accountObservation(id: String) -> AnyPublisher<Account, Error> {
|
||||||
ValueObservation.tracking(AccountInfo.request(AccountRecord.filter(AccountRecord.Columns.id == id)).fetchOne)
|
ValueObservation.tracking(AccountInfo.request(AccountRecord.filter(AccountRecord.Columns.id == id)).fetchOne)
|
||||||
.removeDuplicates()
|
.removeDuplicates()
|
||||||
.map {
|
|
||||||
if let info = $0 {
|
|
||||||
return Account(info: info)
|
|
||||||
} else {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
}
|
|
||||||
.publisher(in: databaseWriter)
|
.publisher(in: databaseWriter)
|
||||||
|
.compactMap { $0 }
|
||||||
|
.map(Account.init(info:))
|
||||||
.eraseToAnyPublisher()
|
.eraseToAnyPublisher()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -35,8 +35,6 @@ public struct ProfileService {
|
||||||
self.contentDatabase = contentDatabase
|
self.contentDatabase = contentDatabase
|
||||||
|
|
||||||
var accountPublisher = contentDatabase.accountObservation(id: accountID)
|
var accountPublisher = contentDatabase.accountObservation(id: accountID)
|
||||||
.compactMap { $0 }
|
|
||||||
.eraseToAnyPublisher()
|
|
||||||
|
|
||||||
if let account = account {
|
if let account = account {
|
||||||
accountPublisher = accountPublisher
|
accountPublisher = accountPublisher
|
||||||
|
|
Loading…
Reference in a new issue