Post status deleted notifications when load fails with not found
This commit is contained in:
parent
fb7a7db6e8
commit
10803408cd
|
@ -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 {
|
||||
|
|
Loading…
Reference in New Issue