From e77c5c4e7800ef6c84f52d674f17a1b9b170c2e2 Mon Sep 17 00:00:00 2001 From: CMK Date: Mon, 26 Jul 2021 15:18:20 +0800 Subject: [PATCH] fix: undo reblog status not remove from timeline issue --- Mastodon/Service/APIService/APIService+Reblog.swift | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Mastodon/Service/APIService/APIService+Reblog.swift b/Mastodon/Service/APIService/APIService+Reblog.swift index fd0206145..88da60f25 100644 --- a/Mastodon/Service/APIService/APIService+Reblog.swift +++ b/Mastodon/Service/APIService/APIService+Reblog.swift @@ -104,7 +104,17 @@ extension APIService { APIService.CoreData.merge(status: oldStatus, entity: entity.reblog ?? entity, requestMastodonUser: requestMastodonUser, domain: mastodonAuthenticationBox.domain, networkDate: response.networkDate) switch reblogKind { case .undoReblog: + // update reblogged status oldStatus.update(reblogsCount: NSNumber(value: max(0, oldStatus.reblogsCount.intValue - 1))) + + // remove reblog from statuses + let reblogFroms = oldStatus.reblogFrom?.filter { status in + return status.author.domain == domain && status.author.id == requestMastodonUserID + } ?? Set() + reblogFroms.forEach { reblogFrom in + managedObjectContext.delete(reblogFrom) + } + default: break }