1
0
mirror of https://github.com/metabolist/metatext synced 2024-12-27 10:12:36 +01:00

Refactoring

This commit is contained in:
Justin Mazzocchi 2020-10-03 13:55:07 -07:00
parent 758c375547
commit 9507343511
No known key found for this signature in database
GPG Key ID: E223E6937AAFB01C
2 changed files with 3 additions and 10 deletions

View File

@ -218,17 +218,12 @@ public extension ContentDatabase {
.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)
.removeDuplicates()
.map {
if let info = $0 {
return Account(info: info)
} else {
return nil
}
}
.publisher(in: databaseWriter)
.compactMap { $0 }
.map(Account.init(info:))
.eraseToAnyPublisher()
}

View File

@ -35,8 +35,6 @@ public struct ProfileService {
self.contentDatabase = contentDatabase
var accountPublisher = contentDatabase.accountObservation(id: accountID)
.compactMap { $0 }
.eraseToAnyPublisher()
if let account = account {
accountPublisher = accountPublisher