diff --git a/DB/Sources/DB/Content/ContentDatabase.swift b/DB/Sources/DB/Content/ContentDatabase.swift index 0f58337..92312d9 100644 --- a/DB/Sources/DB/Content/ContentDatabase.swift +++ b/DB/Sources/DB/Content/ContentDatabase.swift @@ -218,17 +218,12 @@ public extension ContentDatabase { .eraseToAnyPublisher() } - func accountObservation(id: String) -> AnyPublisher { + func accountObservation(id: String) -> AnyPublisher { 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() } diff --git a/ServiceLayer/Sources/ServiceLayer/Services/ProfileService.swift b/ServiceLayer/Sources/ServiceLayer/Services/ProfileService.swift index 3352bf7..ce5205e 100644 --- a/ServiceLayer/Sources/ServiceLayer/Services/ProfileService.swift +++ b/ServiceLayer/Sources/ServiceLayer/Services/ProfileService.swift @@ -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