From 9dce94c014e48f9723415c3dd6a5033626cd6288 Mon Sep 17 00:00:00 2001 From: Shadowfacts Date: Sun, 6 Sep 2020 16:01:19 -0400 Subject: [PATCH] Fix acounts not updating locally Fix reblogged statuses potentially not updating --- Tusker/CoreData/StatusMO.swift | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/Tusker/CoreData/StatusMO.swift b/Tusker/CoreData/StatusMO.swift index 20b963bc..88297a9f 100644 --- a/Tusker/CoreData/StatusMO.swift +++ b/Tusker/CoreData/StatusMO.swift @@ -124,9 +124,19 @@ extension StatusMO { self.uri = status.uri self.url = status.url self.visibility = status.visibility - self.account = container.account(for: status.account.id, in: context) ?? AccountMO(apiAccount: status.account, container: container, context: context) + if let existing = container.account(for: status.account.id, in: context) { + existing.updateFrom(apiAccount: status.account, container: container) + self.account = existing + } else { + self.account = AccountMO(apiAccount: status.account, container: container, context: context) + } if let reblog = status.reblog { - self.reblog = container.status(for: reblog.id, in: context) ?? StatusMO(apiStatus: reblog, container: container, context: context) + if let existing = container.status(for: reblog.id, in: context) { + existing.updateFrom(apiStatus: reblog, container: container) + self.reblog = existing + } else { + self.reblog = StatusMO(apiStatus: reblog, container: container, context: context) + } } else { self.reblog = nil }