diff --git a/Tusker/API/FetchStatusService.swift b/Tusker/API/FetchStatusService.swift index 4d540df9..bf944b6d 100644 --- a/Tusker/API/FetchStatusService.swift +++ b/Tusker/API/FetchStatusService.swift @@ -36,7 +36,24 @@ class FetchStatusService { } private func handleStatusNotFound() { - // todo: remove from persistent store, send notifications + // todo: what about when browsing on another instance? + guard let accountID = mastodonController.accountInfo?.id else { + return + } + + var reblogIDs = [String]() + if let cached = mastodonController.persistentContainer.status(for: statusID) { + let reblogsReq = StatusMO.fetchRequest() + reblogsReq.predicate = NSPredicate(format: "reblog = %@", cached) + if let reblogs = try? mastodonController.persistentContainer.viewContext.fetch(reblogsReq) { + reblogIDs = reblogs.map(\.id) + } + } + + NotificationCenter.default.post(name: .statusDeleted, object: nil, userInfo: [ + "accountID": accountID, + "statusIDs": [statusID] + reblogIDs + ]) } enum Result {