From b749d0a7bcb91e217103ee8eebb2a51c9b8408ce Mon Sep 17 00:00:00 2001 From: CMK Date: Tue, 2 Feb 2021 16:04:39 +0800 Subject: [PATCH] fix: Toot.emojis wrong keyPath issue --- CoreDataStack/Entity/Toot.swift | 11 ++++++----- .../Persist/APIService+Persist+Timeline.swift | 14 +++++++++++++- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/CoreDataStack/Entity/Toot.swift b/CoreDataStack/Entity/Toot.swift index 59ef034dd..a0908d9de 100644 --- a/CoreDataStack/Entity/Toot.swift +++ b/CoreDataStack/Entity/Toot.swift @@ -93,7 +93,7 @@ public extension Toot { } if let emojis = property.emojis { - toot.mutableSetValue(forKey: #keyPath(Toot.mentions)).addObjects(from: emojis) + toot.mutableSetValue(forKey: #keyPath(Toot.emojis)).addObjects(from: emojis) } if let tags = property.tags { @@ -123,10 +123,11 @@ public extension Toot { if let bookmarkedBy = property.bookmarkedBy { toot.mutableSetValue(forKey: #keyPath(Toot.bookmarkedBy)).add(bookmarkedBy) } - if let pinnedBy = property.pinnedBy { - toot.mutableSetValue(forKey: #keyPath(Toot.pinnedBy)) - } - + + // TODO: not implement yet + // if let pinnedBy = property.pinnedBy { + // toot.mutableSetValue(forKey: #keyPath(Toot.pinnedBy)) + // } toot.updatedAt = property.updatedAt toot.deletedAt = property.deletedAt diff --git a/Mastodon/Service/Persist/APIService+Persist+Timeline.swift b/Mastodon/Service/Persist/APIService+Persist+Timeline.swift index 2fc645a88..d3e9ed5eb 100644 --- a/Mastodon/Service/Persist/APIService+Persist+Timeline.swift +++ b/Mastodon/Service/Persist/APIService+Persist+Timeline.swift @@ -72,6 +72,18 @@ extension APIService.Persist { homeTimelineIndexes: nil) Toot.insert(into: managedObjectContext, property: tootProperty, author: author) } - }.eraseToAnyPublisher() + } + .handleEvents(receiveOutput: { result in + switch result { + case .success: + break + case .failure(let error): + #if DEBUG + debugPrint(error) + #endif + assertionFailure(error.localizedDescription) + } + }) + .eraseToAnyPublisher() } }