chore: code error fix

This commit is contained in:
sunxiaojian 2021-02-04 11:12:17 +08:00
parent 1f7819565e
commit ee663cc18f
4 changed files with 7 additions and 5 deletions

View File

@ -23,6 +23,8 @@ extension Item: Equatable {
switch (lhs, rhs) {
case (.toot(let objectIDLeft), .toot(let objectIDRight)):
return objectIDLeft == objectIDRight
case (.bottomLoader, .bottomLoader):
return true
default:
return false
}

View File

@ -40,7 +40,7 @@ extension PublicTimelineViewModel: NSFetchedResultsControllerDelegate {
let indexes = tootIDs.value
let toots = fetchedResultsController.fetchedObjects ?? []
guard toots.count == indexes.count else { return }
let items: [Item] = toots
.compactMap { toot -> (Int, Toot)? in
guard toot.deletedAt == nil else { return nil }

View File

@ -48,7 +48,7 @@ extension APIService.CoreData {
} else {
let (mastodonUser, isMastodonUserCreated) = createOrMergeMastodonUser(into: managedObjectContext, for: requestMastodonUser,in: domain, entity: entity.account, networkDate: networkDate, log: log)
let application = entity.application.flatMap { (app) -> Application? in
let application = entity.application.flatMap { app -> Application? in
Application.insert(into: managedObjectContext, property: Application.Property(name: app.name, website: app.website, vapidKey: app.vapidKey))
}
@ -122,8 +122,8 @@ extension APIService.CoreData {
// merge user
mergeMastodonUser(for: requestMastodonUser, old: toot.author, in: domain, entity: entity.account, networkDate: networkDate)
// merge indirect reblog & quote
if let reblog = entity.reblog {
mergeToot(for: requestMastodonUser, old: toot.reblog!,in: domain, entity: reblog, networkDate: networkDate)
if let reblog = toot.reblog, let reblogEntity = entity.reblog {
mergeToot(for: requestMastodonUser, old: reblog,in: domain, entity: reblogEntity, networkDate: networkDate)
}
}

View File

@ -27,7 +27,7 @@ extension APIService.Persist {
let _ = toots.map {
let userProperty = MastodonUser.Property(id: $0.account.id, domain: domain, acct: $0.account.acct, username: $0.account.username, displayName: $0.account.displayName,avatar: $0.account.avatar,avatarStatic: $0.account.avatarStatic, createdAt: $0.createdAt, networkDate: $0.createdAt)
let author = MastodonUser.insert(into: managedObjectContext, property: userProperty)
let application = $0.application.flatMap { (app) -> Application? in
let application = $0.application.flatMap { app -> Application? in
Application.insert(into: managedObjectContext, property: Application.Property(name: app.name, website: app.website, vapidKey: app.vapidKey))
}
let metions = $0.mentions?.compactMap({ (mention) -> Mention in