Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions OBAKit/Bookmarks/ManageBookmarksAndGroupsViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,13 @@ class ManageBookmarksAndGroupsViewController: UIViewController {
groupsController.view.pinToSuperview(.edges)
}
else {
// Persist group additions/deletions/renames so the bookmarks
// tab sees the current groups when it rebuilds its sections.
groupsController.updateModelState()
removeChildController(groupsController)
addChildController(bookmarksController)
bookmarksController.view.pinToSuperview(.edges)
bookmarksController.reloadFormFromStore()
}
}
}
20 changes: 13 additions & 7 deletions OBAKit/Bookmarks/ManageBookmarksViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,18 @@ class ManageBookmarksViewController: FormViewController {
}
}

/// Rebuilds the form from the current userDataStore on the next run loop iteration.
/// Deferral avoids index-out-of-bounds inside Eureka during child controller transitions.
/// See: https://github.com/OneBusAway/onebusaway-ios/issues/922
func reloadFormFromStore() {
DispatchQueue.main.async { [weak self] in
guard let self else { return }
UIView.performWithoutAnimation {
self.loadForm()
}
}
}

// MARK: - TableView Delegate Overrides

override func tableView(_ tableView: UITableView, moveRowAt sourceIndexPath: IndexPath, to destinationIndexPath: IndexPath) {
Expand All @@ -57,13 +69,7 @@ class ManageBookmarksViewController: FormViewController {

// Defer refresh to avoid index-out-of-bounds during Eureka's internal animation.
// See: https://github.com/OneBusAway/onebusaway-ios/issues/922
// Use performWithoutAnimation to prevent visual glitches.
DispatchQueue.main.async { [weak self] in
guard let self = self else { return }
UIView.performWithoutAnimation {
self.loadForm()
}
}
reloadFormFromStore()
}

override func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCell.EditingStyle, forRowAt indexPath: IndexPath) {
Expand Down
Loading