mirror of
https://github.com/FBukovina/Atoll.git
synced 2026-10-27 23:24:32 +00:00
small improvements
This commit is contained in:
parent
3684802398
commit
f7fbb81d36
16 changed files with 834 additions and 49 deletions
|
|
@ -83,6 +83,19 @@ final class ShelfSelectionModel: ObservableObject {
|
|||
lastAnchorID = nil
|
||||
}
|
||||
|
||||
func reconcileSelection(with allItems: [ShelfItem]) {
|
||||
let validIDs = Set(allItems.map(\.id))
|
||||
let filteredSelection = selectedIDs.intersection(validIDs)
|
||||
|
||||
if filteredSelection != selectedIDs {
|
||||
selectedIDs = filteredSelection
|
||||
}
|
||||
|
||||
if let anchor = lastAnchorID, !validIDs.contains(anchor) {
|
||||
lastAnchorID = selectedIDs.first
|
||||
}
|
||||
}
|
||||
|
||||
// Keep anchor sane if items array changed drastically (optional helper)
|
||||
func ensureValidAnchor(in allItems: [ShelfItem]) {
|
||||
if let anchor = lastAnchorID, !allItems.contains(where: { $0.id == anchor }) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue