Fix dish deletion list flicker with stable identity/order and add regression test
This commit is contained in:
@@ -23,3 +23,14 @@ final class Dish {
|
||||
self.createdAt = createdAt
|
||||
}
|
||||
}
|
||||
|
||||
extension Dish {
|
||||
static func stableSortedForDisplay(_ dishes: [Dish]) -> [Dish] {
|
||||
dishes.sorted { lhs, rhs in
|
||||
if lhs.createdAt != rhs.createdAt {
|
||||
return lhs.createdAt > rhs.createdAt
|
||||
}
|
||||
return lhs.id.uuidString < rhs.id.uuidString
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user