Fix issue with deleting status from timeline

This commit is contained in:
Marcin Czachurski 2023-04-26 15:49:12 +02:00
parent 3755213931
commit cab647636c
3 changed files with 6 additions and 11 deletions

View File

@ -172,20 +172,15 @@ public class HomeTimelineService {
// Collection with statuses to remove from database. // Collection with statuses to remove from database.
var dbStatusesToRemove: [StatusData] = [] var dbStatusesToRemove: [StatusData] = []
let allDbStatuses = StatusDataHandler.shared.getAllStatuses(accountId: account.id, viewContext: backgroundContext)
// Find statuses to delete (older then the last one from API). // Find statuses to delete (not exiting in the API results).
if let lastStatus = statuses.last { for dbStatus in allDbStatuses where !statuses.contains(where: { status in status.id == dbStatus.id }) {
let dbOlderStatuses = StatusDataHandler.shared.getAllOlderStatuses(accountId: account.id, dbStatusesToRemove.append(dbStatus)
statusId: lastStatus.id,
viewContext: backgroundContext)
if !dbOlderStatuses.isEmpty {
dbStatusesToRemove.append(contentsOf: dbOlderStatuses)
}
} }
// Find statuses to delete (duplicates). // Find statuses to delete (duplicates).
var existingStatusIds: [String] = [] var existingStatusIds: [String] = []
let allDbStatuses = StatusDataHandler.shared.getAllStatuses(accountId: account.id, viewContext: backgroundContext)
for dbStatus in allDbStatuses { for dbStatus in allDbStatuses {
if existingStatusIds.contains(where: { $0 == dbStatus.id }) { if existingStatusIds.contains(where: { $0 == dbStatus.id }) {
dbStatusesToRemove.append(dbStatus) dbStatusesToRemove.append(dbStatus)

View File

@ -1,7 +1,7 @@
// //
// https://mczachurski.dev // https://mczachurski.dev
// Copyright © 2023 Marcin Czachurski and the repository contributors. // Copyright © 2023 Marcin Czachurski and the repository contributors.
// Licensed under the MIT License. // Licensed under the Apache License 2.0.
// //
import Foundation import Foundation

View File

@ -31,7 +31,7 @@ public struct TagWidget: View {
.fontWeight(.semibold) .fontWeight(.semibold)
} }
.padding(.horizontal, 10) .padding(.horizontal, 10)
.padding(.vertical, 6) .padding(.vertical, 4)
.background(Capsule().foregroundColor(self.color)) .background(Capsule().foregroundColor(self.color))
} }
} }