Skip to content

Commit a91229c

Browse files
authored
Fix onChange warnings (#24975)
1 parent d34c401 commit a91229c

File tree

14 files changed

+27
-22
lines changed

14 files changed

+27
-22
lines changed

Modules/Sources/JetpackStats/Cards/RealtimeTopListCard.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ struct RealtimeTopListCard: View {
4242
}
4343
.padding(.vertical, Constants.step3)
4444
.redacted(reason: viewModel.isFirstLoad ? .placeholder : [])
45-
.onChange(of: selectedItem) { newValue in
45+
.onChange(of: selectedItem) { oldValue, newValue in
4646
viewModel.loadData(for: newValue)
4747
}
4848
}

Modules/Sources/JetpackStats/Charts/BarChartView.swift

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ struct BarChartView: View {
4242
.accessibilityElement()
4343
.accessibilityLabel(Strings.Accessibility.chartContainer)
4444
.accessibilityHint(Strings.Accessibility.viewChartData)
45-
.onChange(of: ObjectIdentifier(data)) { _ in
45+
.onChange(of: ObjectIdentifier(data)) {
4646
tappedDataPoint = nil
4747
}
4848
}
@@ -287,7 +287,12 @@ struct BarChartView: View {
287287
}
288288

289289
private func getSelectedDataPoints(at location: CGPoint, proxy: ChartProxy, geometry: GeometryProxy) -> SelectedDataPoints? {
290-
let origin = geometry[proxy.plotAreaFrame].origin
290+
291+
guard let frame = proxy.plotFrame else {
292+
return nil
293+
}
294+
295+
let origin = geometry[frame].origin
291296
let location = CGPoint(
292297
x: location.x - origin.x,
293298
y: location.y - origin.y

Modules/Sources/JetpackStats/Charts/LineChartView.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ struct LineChartView: View {
3535
.chartXSelection(value: $selectedDate)
3636
.animation(.spring, value: ObjectIdentifier(data))
3737
.onChange(of: selectedDate) {
38-
selectedDataPoints = SelectedDataPoints.compute(for: $0, data: data)
38+
selectedDataPoints = SelectedDataPoints.compute(for: $1, data: data)
3939
}
4040
.dynamicTypeSize(...DynamicTypeSize.xxxLarge)
4141
.accessibilityElement()

Modules/Sources/JetpackStats/Screens/AuthorStatsView.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ struct AuthorStatsView: View {
5555
}
5656
.background(Constants.Colors.background)
5757
.animation(.spring, value: viewModel.data.map(ObjectIdentifier.init))
58-
.onChange(of: dateRange) { newRange in
59-
viewModel.dateRange = newRange
58+
.onChange(of: dateRange) { oldValue, newValue in
59+
viewModel.dateRange = newValue
6060
}
6161
.onAppear {
6262
context.tracker?.send(.authorStatsScreenShown)

Modules/Sources/JetpackStats/Screens/StatsMainView.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public struct StatsMainView: View {
3636
.onAppear {
3737
context.tracker?.send(.statsMainScreenShown)
3838
}
39-
.onChange(of: selectedTab) { newValue in
39+
.onChange(of: selectedTab) { oldValue, newValue in
4040
trackTabChange(from: selectedTab, to: newValue)
4141
}
4242
} else {

Modules/Sources/JetpackStats/Views/CustomDateRangePicker.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ struct CustomDateRangePicker: View {
116116
private var dateSelectionSection: some View {
117117
HStack(alignment: .bottom, spacing: 0) {
118118
datePickerColumn(label: Strings.DatePicker.from.uppercased(), selection: $startDate, alignment: .leading)
119-
.onChange(of: startDate) { newValue in
119+
.onChange(of: startDate) { oldValue, newValue in
120120
// If start date is after end date, adjust end date to be one day after start
121121
if newValue > endDate {
122122
endDate = calendar.date(byAdding: .day, value: 1, to: newValue) ?? newValue
@@ -126,7 +126,7 @@ struct CustomDateRangePicker: View {
126126
Spacer(minLength: 32)
127127

128128
datePickerColumn(label: Strings.DatePicker.to.uppercased(), selection: $endDate, alignment: .trailing)
129-
.onChange(of: endDate) { newValue in
129+
.onChange(of: endDate) { oldValue, newValue in
130130
// If end date is before start date, adjust start date to be one day before end
131131
if newValue < startDate {
132132
startDate = calendar.date(byAdding: .day, value: -1, to: newValue) ?? newValue

Modules/Sources/JetpackStats/Views/Customization/TopListCardCustomizationView.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ struct TopListCardCustomizationView: View {
3939
}
4040
}
4141
}
42-
.onChange(of: selectedItem) { newValue in
42+
.onChange(of: selectedItem) { oldValue, newValue in
4343
if let newValue {
4444
updateConfiguration(with: newValue)
4545
}

Modules/Sources/Support/UI/Support Conversations/SupportConversationView.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ public struct SupportConversationView: View {
141141
.onAppear {
142142
scrollToBottom(proxy: proxy)
143143
}
144-
.onChange(of: conversation.messages.count) { _, _ in
144+
.onChange(of: conversation.messages.count) {
145145
scrollToBottom(proxy: proxy)
146146
}
147147
}

WordPress/Classes/ViewRelated/Blog/Blogging Prompts/Bloganuary/BloganuaryOverlayViewController.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ private struct BloganuaryOverlayView: View {
142142
.onAppear {
143143
scrollViewHeight = geo.size.height
144144
}
145-
.onChange(of: viewModel.orientation) { _ in
145+
.onChange(of: viewModel.orientation) {
146146
// since onAppear is only called once, assign the value again every time the orientation changes.
147147
scrollViewHeight = geo.size.height
148148
}

WordPress/Classes/ViewRelated/Blog/Site Monitoring/PHPLogsView.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ struct PHPLogsView: View {
2121
.onAppear {
2222
loadLogs(searchCriteria: searchCriteria)
2323
}
24-
.onChange(of: searchCriteria) { value in
25-
loadLogs(searchCriteria: value, reset: true)
24+
.onChange(of: searchCriteria) { oldValue, newValue in
25+
loadLogs(searchCriteria: newValue, reset: true)
2626
}
2727
}
2828

0 commit comments

Comments
 (0)