commit 06bc7415b3de62fbb42173f0a672a0d7c9c58f40
parent 27ce8422d39fe3be1677bf307d0cc345c6bde185
Author: Michael Camilleri <[email protected]>
Date: Wed, 21 Oct 2026 11:31:18 +0900
Rename and fix items in Data section of Settings
Tapping 'Export Reports' crashed the app as soon as the export was
written. The file handed to the save sheet suggested no name, so
SwiftUI gave the file it saves an empty one, which Foundation rejects
with an exception. The export now suggests its own file name, such as
'Reportage 2026-10-21.json', and the save sheet opens with it.
This commit also renames the actions in the Data section of Settings:
'Import from Reporter' becomes 'Import Reports', ahead of importing
Reportage's own exports; 'Fill In Health Data' becomes 'Backfill Health
Data'; and 'Update Addresses' becomes 'Upgrade Address Format', which no
longer explains itself beneath the button before it's started. Its
progress and outcome read 'Upgraded' to match. The Debug section, in
debug builds, now follows Diagnostics rather than Miscellaneous.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Diffstat
| M | Notes/Design.md | | | 10 | +++++----- |
| M | Reportage/Views/Settings/DataSection.swift | | | 45 | +++++++++++++++++++++++++-------------------- |
| M | Reportage/Views/Settings/SettingsView.swift | | | 6 | +++--- |
3 files changed, 33 insertions(+), 28 deletions(-)
diff --git a/Notes/Design.md b/Notes/Design.md
@@ -405,7 +405,7 @@ more than one provider exists over time. its region, the full and short addresses, and the language they're in, with the address in other languages beside it (see [Location](#location)). Imported reports have Reporter's placemark (thoroughfare, locality, - administrative area, postal code and so on) until **Update Addresses** + administrative area, postal code and so on) until **Upgrade Address Format** replaces it. - `weather`: normalised to metric: condition, temperature, feels-like, dew point, humidity, pressure, wind speed, gust and direction, visibility, UV, @@ -697,7 +697,7 @@ and the full and short addresses. Reverse geocoding uses MapKit's place's local language when that differs (worked out from the first result's country: `ja` for Japan, `zh-Hant` for Taiwan), so the placemark can be shown by the same rule as place names. Apple throttles geocoding: two requests per -report is fine, and **Update Addresses** (see [Behaviour](#behaviour)) looks +report is fine, and **Upgrade Address Format** (see [Behaviour](#behaviour)) looks up older addresses again at the pace it allows. ### Weather @@ -742,7 +742,7 @@ once more, so it can ask. Reports filed after Health was first asked for are filled in automatically: as soon as they're saved if the iPhone is unlocked, and otherwise the next time the app comes to the foreground. Earlier reports, the imported archive included, are filled in only when the -user asks, with **Fill In Health Data** in Settings' Data section. It works +user asks, with **Backfill Health Data** in Settings' Data section. It works newest first and in batches, and can be stopped and run again; it skips reports already settled. @@ -907,7 +907,7 @@ Source: Reporter's JSON export, which has two top-level arrays, `questions` and ### Behaviour - Runs on the iPhone only, off the main actor, inserting in batches. It's - started from **Import from Reporter** in Settings' Data section, which picks + started from **Import Reports** in Settings' Data section, which picks the export with `fileImporter` and shows the counts when it's done; the full summary goes to the log, as counts and IDs only. - **Idempotent and repeatable.** Reports, questions and tokens keep their @@ -925,7 +925,7 @@ Source: Reporter's JSON export, which has two top-level arrays, `questions` and - **Addresses are updated to MapKit's form afterwards.** Reporter's addresses came from the geocoder of their day, in whatever language the device used, without the country code or city with its region that - MapKit gives. **Update Addresses** in Settings' Data section looks each + MapKit gives. **Upgrade Address Format** in Settings' Data section looks each one up again as capture does, in the user's first language and the place's own, and replaces it. Reports within 25 m of each other share a lookup, since a fix is rarely better
diff --git a/Reportage/Views/Settings/DataSection.swift b/Reportage/Views/Settings/DataSection.swift
@@ -34,7 +34,7 @@ struct DataSection: View {
Button {
isChoosingImport = true
} label: {
- TaskLabel("Import from Reporter", isRunning: task == .importing)
+ TaskLabel("Import Reports", isRunning: task == .importing)
}
.disabled(task != nil || store == nil || addressUpdater?.isUpdating == true)
.settingsRow()
@@ -54,7 +54,7 @@ struct DataSection: View {
}
} label: {
TaskLabel(
- healthFiller.isFillingPast ? "Stop Filling In Health Data" : "Fill In Health Data",
+ healthFiller.isFillingPast ? "Stop Backfilling Health Data" : "Backfill Health Data",
isRunning: healthFiller.isFillingPast)
}
.disabled(task != nil || store == nil)
@@ -74,12 +74,12 @@ struct DataSection: View {
}
} label: {
TaskLabel(
- addressUpdater.isUpdating ? "Stop Updating Addresses" : "Update Addresses",
+ addressUpdater.isUpdating ? "Stop Upgrading Address Format" : "Upgrade Address Format",
isRunning: addressUpdater.isUpdating)
}
.disabled(task == .importing || task == .deleting || store == nil)
.settingsRow()
- SettingsNote { AddressNote(updater: addressUpdater) }
+ AddressNote(updater: addressUpdater)
}
Button(role: .destructive) {
isConfirmingDelete = true
@@ -245,28 +245,30 @@ struct DataSection: View {
}
}
-/// What updating addresses does, how far it has got, or how it ended.
+/// How far upgrading addresses has got, or how it ended.
private struct AddressNote: View {
let updater: AddressUpdater
var body: some View {
+ if let text {
+ SettingsNote { text }
+ }
+ }
+
+ private var text: Text? {
if let progress = updater.progress {
- if progress.isWaiting {
- Text("Updated \(progress.updated) of \(progress.total) reports. Waiting for Apple Maps, which limits how often addresses can be looked up…")
- } else {
- Text("Updated \(progress.updated) of \(progress.total) reports. Keep Reportage open until it finishes; the screen stays on meanwhile.")
- }
- } else if let outcome = updater.outcome {
- if outcome.updated + outcome.unfound < outcome.total {
- Text("Updated \(outcome.updated) of \(outcome.total) reports before stopping. Update again to carry on.")
- } else if outcome.unfound > 0 {
- Text("Updated ^[\(outcome.updated) report](inflect: true). Apple Maps had no address for ^[\(outcome.unfound) report](inflect: true), which kept the one it had.")
- } else {
- Text("Updated ^[\(outcome.updated) report](inflect: true).")
- }
- } else {
- Text("Gives reports imported from Reporter, or filed before their address was found, the address Apple Maps gives new reports.")
+ return progress.isWaiting
+ ? Text("Upgraded \(progress.updated) of \(progress.total) reports. Waiting for Apple Maps, which limits how often addresses can be looked up…")
+ : Text("Upgraded \(progress.updated) of \(progress.total) reports. Keep Reportage open until it finishes; the screen stays on meanwhile.")
+ }
+ guard let outcome = updater.outcome else { return nil }
+ if outcome.updated + outcome.unfound < outcome.total {
+ return Text("Upgraded \(outcome.updated) of \(outcome.total) reports before stopping. Upgrade again to carry on.")
+ }
+ if outcome.unfound > 0 {
+ return Text("Upgraded ^[\(outcome.updated) report](inflect: true). Apple Maps had no address for ^[\(outcome.unfound) report](inflect: true), which kept the one it had.")
}
+ return Text("Upgraded ^[\(outcome.updated) report](inflect: true).")
}
}
@@ -300,5 +302,8 @@ private struct ExportFile: Transferable {
FileRepresentation(exportedContentType: .json) { file in
SentTransferredFile(file.url)
}
+ // Without a name, the file exporter crashes setting the empty name
+ // on the file it saves.
+ .suggestedFileName { $0.url.lastPathComponent }
}
}
diff --git a/Reportage/Views/Settings/SettingsView.swift b/Reportage/Views/Settings/SettingsView.swift
@@ -34,15 +34,15 @@ struct SettingsView: View {
}
DataSection()
DiagnosticsSection()
+ #if DEBUG
+ WelcomeReplay { isShowingWelcome = true }
+ #endif
Section {
NavigationLink("About") { AboutView() }
.settingsRow()
} header: {
SettingsHeading("Miscellaneous")
}
- #if DEBUG
- WelcomeReplay { isShowingWelcome = true }
- #endif
}
.listStyle(.plain)
.scrollContentBackground(.hidden)