Skip to content

Commit 34831da

Browse files
committed
Remove unneeded properties.
1 parent 0f55a77 commit 34831da

File tree

1 file changed

+3
-18
lines changed

1 file changed

+3
-18
lines changed

Shared/Supporting Files/Views/DownloadOfflineResourcesView.swift

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,6 @@ import SwiftUI
1616

1717
/// A view with controls for downloading the app's on-demand resources.
1818
struct DownloadOfflineResourcesView: View {
19-
/// The samples that require offline resources.
20-
let samples = SamplesApp.samples.filter(\.hasDependencies)
21-
2219
/// The action to dismiss the view.
2320
@Environment(\.dismiss) private var dismiss
2421

@@ -44,11 +41,6 @@ struct DownloadOfflineResourcesView: View {
4441
}
4542
}
4643

47-
/// Returns the on-demand resource for the given sample.
48-
func resource(for sample: Sample) -> OnDemandResource? {
49-
return onDemandResources[sample.name]
50-
}
51-
5244
var body: some View {
5345
NavigationStack {
5446
Form {
@@ -74,10 +66,8 @@ struct DownloadOfflineResourcesView: View {
7466
.disabled(onDemandResources.isEmpty || isDownloadingAll || allResourcesAreDownloaded)
7567
}
7668
Section {
77-
List(samples, id: \.name) { sample in
78-
if let resource = resource(for: sample) {
79-
DownloadOnDemandResourceView(name: sample.name, resource: resource)
80-
}
69+
List(onDemandResources.sorted(by: { $0.key < $1.key }), id: \.key) { name, resource in
70+
DownloadOnDemandResourceView(name: name, resource: resource)
8171
}
8272
} footer: {
8373
Text("**Note**: The system may purge downloads at any time.")
@@ -104,7 +94,7 @@ struct DownloadOfflineResourcesView: View {
10494
.task {
10595
guard onDemandResources.isEmpty else { return }
10696
onDemandResources = await withTaskGroup { group in
107-
for sample in samples {
97+
for sample in SamplesApp.samples where sample.hasDependencies {
10898
group.addTask {
10999
let resource = await OnDemandResource(tags: sample.odrTags)
110100
return (sample.name, resource)
@@ -141,11 +131,6 @@ struct DownloadOfflineResourcesView: View {
141131
}
142132
}
143133
}
144-
145-
// Automatically dismisses the view if all of the resources have downloaded successfully.
146-
if allResourcesAreDownloaded {
147-
dismiss()
148-
}
149134
}
150135
}
151136

0 commit comments

Comments
 (0)