Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes various retain cycles #541

Merged
merged 2 commits into from
Oct 4, 2021
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
11 changes: 8 additions & 3 deletions OBAKit/Controls/ListView/OBAListView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public class OBAListView: UICollectionView, UICollectionViewDelegate {
// MARK: - Data source

fileprivate func createDataSource() -> UICollectionViewDiffableDataSource<SectionType, ItemType> {
let dataSource = UICollectionViewDiffableDataSource<SectionType, ItemType>(collectionView: self) { (collectionView, indexPath, item) -> UICollectionViewCell? in
let dataSource = UICollectionViewDiffableDataSource<SectionType, ItemType>(collectionView: self) { [unowned self] (collectionView, indexPath, item) -> UICollectionViewCell? in

switch item.configuration {
case .custom(let config):
Expand Down Expand Up @@ -231,8 +231,13 @@ public class OBAListView: UICollectionView, UICollectionViewDelegate {
return configuration
}

configuration.leadingSwipeActionsConfigurationProvider = self.leadingSwipeActions
configuration.trailingSwipeActionsConfigurationProvider = self.trailingSwipeActions
configuration.leadingSwipeActionsConfigurationProvider = { [unowned self] indexPath -> UISwipeActionsConfiguration? in
leadingSwipeActions(for: indexPath)
}

configuration.trailingSwipeActionsConfigurationProvider = { [unowned self] indexPath -> UISwipeActionsConfiguration? in
trailingSwipeActions(for: indexPath)
}

return NSCollectionLayoutSection.list(using: configuration, layoutEnvironment: environment)
}
Expand Down
2 changes: 1 addition & 1 deletion OBAKit/Stops/StopViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,7 @@ public class StopViewController: UIViewController,
title = Strings.updating

let op = apiService.getArrivalsAndDeparturesForStop(id: stopID, minutesBefore: minutesBefore, minutesAfter: minutesAfter)
op.complete { [weak self] result in
op.complete { [weak self, unowned op] result in
guard let self = self else { return }

let broken = self.bookmarkContext != nil && (op.statusCodeIsEffectively404 ?? false)
Expand Down