forked from shadowfacts/Tusker
Fix reblogged statuses being pruned while still referenced, add workaround for crash
This commit is contained in:
parent
23f383a7f9
commit
34edd8a13f
|
@ -123,7 +123,8 @@
|
|||
<attribute name="url" optional="YES" attributeType="URI"/>
|
||||
<attribute name="visibilityString" attributeType="String"/>
|
||||
<relationship name="account" optional="YES" maxCount="1" deletionRule="Nullify" destinationEntity="Account" inverseName="statuses" inverseEntity="Account"/>
|
||||
<relationship name="reblog" optional="YES" maxCount="1" deletionRule="Nullify" destinationEntity="Status"/>
|
||||
<relationship name="reblog" optional="YES" maxCount="1" deletionRule="Nullify" destinationEntity="Status" inverseName="reblogs" inverseEntity="Status"/>
|
||||
<relationship name="reblogs" optional="YES" maxCount="1" deletionRule="Nullify" destinationEntity="Status" inverseName="reblog" inverseEntity="Status"/>
|
||||
<relationship name="timelines" optional="YES" toMany="YES" deletionRule="Nullify" destinationEntity="TimelineState" inverseName="statuses" inverseEntity="TimelineState"/>
|
||||
<uniquenessConstraints>
|
||||
<uniquenessConstraint>
|
||||
|
|
|
@ -148,7 +148,7 @@ class MainSceneDelegate: UIResponder, UIWindowSceneDelegate, TuskerSceneDelegate
|
|||
minDate.addTimeInterval(-7 * 24 * 60 * 60)
|
||||
|
||||
let statusReq: NSFetchRequest<NSFetchRequestResult> = StatusMO.fetchRequest()
|
||||
statusReq.predicate = NSPredicate(format: "(lastFetchedAt = nil) OR (lastFetchedAt < %@)", minDate as NSDate)
|
||||
statusReq.predicate = NSPredicate(format: "((lastFetchedAt = nil) OR (lastFetchedAt < %@)) AND (reblogs.@count = 0)", minDate as NSDate)
|
||||
let deleteStatusReq = NSBatchDeleteRequest(fetchRequest: statusReq)
|
||||
deleteStatusReq.resultType = .resultTypeCount
|
||||
if let res = try? context.execute(deleteStatusReq) as? NSBatchDeleteResult {
|
||||
|
|
|
@ -445,6 +445,16 @@ class TimelineViewController: UIViewController, TimelineLikeCollectionViewContro
|
|||
if let status = mastodonController.persistentContainer.status(for: id) {
|
||||
// touch the status so that, even if it's old, it doesn't get pruned when we go into the background
|
||||
status.touch()
|
||||
|
||||
// there was a bug where th the reblogged status would get pruned even when it was still refernced by the reblog
|
||||
// as a temporary workaround, until there are no longer user db's in this state,
|
||||
// check if the reblog is invalid and reload the status if so
|
||||
if let reblog = status.reblog,
|
||||
// force the fault to fire
|
||||
case _ = reblog.id,
|
||||
reblog.isDeleted {
|
||||
unloaded.append(id)
|
||||
}
|
||||
} else {
|
||||
unloaded.append(id)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue