Enforce Rust and Swift ownership boundary
This commit is contained in:
@@ -303,17 +303,6 @@ final class HomeViewController: RefreshingTableViewController {
|
||||
case all
|
||||
case issues
|
||||
case pulls
|
||||
|
||||
func includes(_ row: ActivityRow) -> Bool {
|
||||
switch self {
|
||||
case .all:
|
||||
return true
|
||||
case .issues:
|
||||
return row.icon.contains("issue")
|
||||
case .pulls:
|
||||
return row.icon.contains("pull")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private let context: AppContext
|
||||
@@ -321,7 +310,12 @@ final class HomeViewController: RefreshingTableViewController {
|
||||
private var filter = ActivityFilter.all
|
||||
|
||||
private var activities: [ActivityRow] {
|
||||
page?.activities.filter(filter.includes) ?? []
|
||||
guard let page else { return [] }
|
||||
switch filter {
|
||||
case .all: return page.activities
|
||||
case .issues: return page.issueActivities
|
||||
case .pulls: return page.pullActivities
|
||||
}
|
||||
}
|
||||
|
||||
init(context: AppContext) {
|
||||
@@ -443,20 +437,7 @@ final class HeatmapView: UIView {
|
||||
private let calendar = Calendar(identifier: .gregorian)
|
||||
|
||||
init(page: HomePage, selectedFilter: Int, onFilter: @escaping (Int) -> Void) {
|
||||
let latest = page.heatCells.last.map {
|
||||
Date(timeIntervalSince1970: TimeInterval($0.timestamp))
|
||||
} ?? Date()
|
||||
let latestMonth = Calendar(identifier: .gregorian).date(
|
||||
from: Calendar(identifier: .gregorian).dateComponents([.year, .month], from: latest)
|
||||
) ?? latest
|
||||
let firstMonth = Calendar(identifier: .gregorian).date(
|
||||
byAdding: .month,
|
||||
value: -8,
|
||||
to: latestMonth
|
||||
) ?? latestMonth
|
||||
cells = page.heatCells.filter {
|
||||
Date(timeIntervalSince1970: TimeInterval($0.timestamp)) >= firstMonth
|
||||
}
|
||||
cells = page.heatCells
|
||||
super.init(frame: CGRect(x: 0, y: 0, width: 0, height: 180))
|
||||
backgroundColor = .systemBackground
|
||||
let title = UILabel(frame: CGRect(x: 16, y: 12, width: 300, height: 22))
|
||||
@@ -465,7 +446,7 @@ final class HeatmapView: UIView {
|
||||
title.textColor = .secondaryLabel
|
||||
addSubview(title)
|
||||
let total = UILabel(frame: CGRect(x: 16, y: 108, width: 300, height: 18))
|
||||
total.text = "\(cells.reduce(0) { $0 + $1.contributions }) contributions"
|
||||
total.text = "\(page.contributionCount) contributions"
|
||||
total.font = .preferredFont(forTextStyle: .caption1)
|
||||
total.textColor = .tertiaryLabel
|
||||
addSubview(total)
|
||||
|
||||
Reference in New Issue
Block a user