Skip to content

Commit 0b04f77

Browse files
authored
Merge pull request #553 from Esri/Caleb/Fix-ShowServiceAreaTaskBug
[Fix] Some Task block bugs
2 parents 1c76a65 + 85a1338 commit 0b04f77

File tree

6 files changed

+22
-9
lines changed

6 files changed

+22
-9
lines changed

Shared/Samples/Create load report/CreateLoadReportView.Model.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,8 @@ extension CreateLoadReportView {
187187
/// - Precondition: `allowsCreateLoadReport`
188188
func createLoadReport() async {
189189
precondition(allowsCreateLoadReport)
190+
allowsCreateLoadReport = false
191+
defer { updateAllowsCreateLoadReport() }
190192

191193
guard let phasesNetworkAttribute,
192194
let initialExpression,

Shared/Samples/Edit feature attachments/EditFeatureAttachmentsView.swift

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -163,12 +163,14 @@ private extension EditFeatureAttachmentsView {
163163

164164
private extension EditFeatureAttachmentsView {
165165
struct AttachmentView: View {
166-
// The attachment that is being displayed.
166+
/// The attachment that is being displayed.
167167
let attachment: Attachment
168-
// The closure called when the delete button is tapped.
168+
/// The closure called when the delete button is tapped.
169169
let onDelete: ((Attachment) -> Void)
170-
// The image in the attachment.
170+
/// The image in the attachment.
171171
@State private var image: Image?
172+
/// The image to show if an image cannot be created from the attachment's data.
173+
private let warningImage = Image(systemName: "exclamationmark.triangle")
172174

173175
var body: some View {
174176
HStack {
@@ -181,7 +183,7 @@ private extension EditFeatureAttachmentsView {
181183
if let uiImage = UIImage(data: result) {
182184
image = Image(uiImage: uiImage)
183185
} else {
184-
image = Image(systemName: "exclamationmark.triangle")
186+
image = warningImage
185187
}
186188
}
187189
} label: {
@@ -194,6 +196,7 @@ private extension EditFeatureAttachmentsView {
194196
Image(systemName: "arrow.down.circle.fill")
195197
}
196198
}
199+
.disabled(image != nil && image != warningImage)
197200
}
198201
.swipeActions {
199202
Button("Delete") {

Shared/Samples/Find closest facility from point/FindClosestFacilityFromPointView.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ struct FindClosestFacilityFromPointView: View {
5555
}
5656
}
5757
}
58-
.disabled(routingIsDisabled)
58+
.disabled(routingIsDisabled || isRouting)
5959

6060
Spacer()
6161

Shared/Samples/Run valve isolation trace/RunValveIsolationTraceView.Model.swift

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ extension RunValveIsolationTraceView {
148148

149149
addGraphic(for: point, traceLocationType: "starting point")
150150
startingLocationPoint = point
151-
tracingActivity = .none
151+
tracingActivity = nil
152152

153153
// Get available utility categories.
154154
if let definition = utilityNetwork.definition {
@@ -224,9 +224,10 @@ extension RunValveIsolationTraceView {
224224
} catch {
225225
statusText = "Trace failed."
226226
traceEnabled = true
227+
tracingActivity = nil
227228
return
228229
}
229-
tracingActivity = .none
230+
tracingActivity = nil
230231
traceEnabled = true
231232
resetEnabled = true
232233
}

Shared/Samples/Run valve isolation trace/RunValveIsolationTraceView.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ struct RunValveIsolationTraceView: View {
8282
Task { await mapViewProxy.setViewpointCenter(point, scale: 3_000) }
8383
}
8484
}
85-
.disabled(!model.resetEnabled)
85+
.disabled(!model.resetEnabled || model.tracingActivity == .runningTrace)
8686
}
8787
}
8888
.sheet(isPresented: $isConfigurationPresented) {

Shared/Samples/Show service area/ShowServiceAreaView.swift

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ struct ShowServiceAreaView: View {
3030
@State private var secondTimeBreak: Int = 8
3131
/// A Boolean value indicating whether the time breaks settings are presented.
3232
@State private var settingsArePresented = false
33+
/// A Boolean value indicating whether the service area is being solved.
34+
@State private var isSolvingServiceArea = false
3335

3436
/// The data model for the sample.
3537
@StateObject private var model = Model()
@@ -76,13 +78,18 @@ struct ShowServiceAreaView: View {
7678
Spacer()
7779
Button("Service Area") {
7880
Task {
81+
isSolvingServiceArea = true
7982
do {
80-
try await model.showServiceArea(timeBreaks: [Double(firstTimeBreak), Double(secondTimeBreak)])
83+
try await model.showServiceArea(
84+
timeBreaks: [Double(firstTimeBreak), Double(secondTimeBreak)]
85+
)
8186
} catch {
8287
self.error = error
8388
}
89+
isSolvingServiceArea = false
8490
}
8591
}
92+
.disabled(isSolvingServiceArea)
8693
Spacer()
8794
Button("Clear", systemImage: "trash") {
8895
model.removeAllGraphics()

0 commit comments

Comments
 (0)