diff --git a/Mastodon/Diffiable/Item/Item.swift b/Mastodon/Diffiable/Item/Item.swift index 85aaabdf7..3113bc5e7 100644 --- a/Mastodon/Diffiable/Item/Item.swift +++ b/Mastodon/Diffiable/Item/Item.swift @@ -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 } diff --git a/Mastodon/Scene/PublicTimeline/PublicTimelineViewModel+Diffable.swift b/Mastodon/Scene/PublicTimeline/PublicTimelineViewModel+Diffable.swift index ca323ee47..6e4e10698 100644 --- a/Mastodon/Scene/PublicTimeline/PublicTimelineViewModel+Diffable.swift +++ b/Mastodon/Scene/PublicTimeline/PublicTimelineViewModel+Diffable.swift @@ -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 } diff --git a/Mastodon/Service/APIService/CoreData/APIService+CoreData+Toot.swift b/Mastodon/Service/APIService/CoreData/APIService+CoreData+Toot.swift index 8f11fa214..b4bdb28bb 100644 --- a/Mastodon/Service/APIService/CoreData/APIService+CoreData+Toot.swift +++ b/Mastodon/Service/APIService/CoreData/APIService+CoreData+Toot.swift @@ -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) } } diff --git a/Mastodon/Service/APIService/Persist/APIService+Persist+Timeline.swift b/Mastodon/Service/APIService/Persist/APIService+Persist+Timeline.swift index 4a8a1c3e6..ec38e5992 100644 --- a/Mastodon/Service/APIService/Persist/APIService+Persist+Timeline.swift +++ b/Mastodon/Service/APIService/Persist/APIService+Persist+Timeline.swift @@ -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