Fix crash on 17.1

This commit is contained in:
Marcin Czachurski 2023-10-26 07:28:07 +02:00
parent e16ebcc2e5
commit 2b88870995
1 changed files with 6 additions and 11 deletions

View File

@ -41,8 +41,11 @@ class ViewedStatusHandler {
do {
let reblogId = reblog.id
let statusId = status.id
var fetchDescriptor = FetchDescriptor<ViewedStatus>(
predicate: #Predicate { $0.pixelfedAccount?.id == accountId && $0.id != status.id && ($0.id == reblogId || $0.reblogId == reblogId) }
// Here we are finding status which is other then checked status AND orginal status has been visible OR same reblogged by different user status has been visible.
predicate: #Predicate { $0.pixelfedAccount?.id == accountId && $0.id != statusId && ($0.id == reblogId || $0.reblogId == reblogId) }
)
fetchDescriptor.fetchLimit = 1
fetchDescriptor.includePendingChanges = true
@ -50,16 +53,8 @@ class ViewedStatusHandler {
guard let first = try modelContext.fetch(fetchDescriptor).first else {
return false
}
if first.reblogId == nil {
return true
}
if first.id != status.id {
return true
}
return false
return true
} catch {
CoreDataError.shared.handle(error, message: "Error during fetching viewed statuses (hasBeenAlreadyOnTimeline).")
return false