@@ -205,101 +205,6 @@ struct TotalStatisticsView: View {
205205 }
206206#endif
207207
208- private struct DatabaseMaintenanceView : View {
209- @Environment ( AppState . self) private var appState
210- @State private var hasMigratedLegacyDatabase = false
211- @State private var hasLegacyDatabase = false
212- @State private var performingDatabaseMaintenance = false
213-
214- var body : some View {
215- Form {
216- Section {
217- LabeledContent ( " Database type " ) {
218- if hasLegacyDatabase {
219- // This shouldn't happen because either the migration fails or the app runs, but if it does happen
220- // we want to know (and therefore indicate it in the UI).
221- Text ( " v1 " ) . foregroundStyle ( . red)
222- }
223- else {
224- Text ( " v2 " )
225- }
226- }
227-
228- if appState. userSettings. migratedToV2At > 0.0 {
229- LabeledContent ( " Upgraded at " ) {
230- Text (
231- Date ( timeIntervalSinceReferenceDate: appState. userSettings. migratedToV2At) . formatted (
232- date: . abbreviated, time: . shortened) )
233- }
234- }
235- }
236-
237- if hasLegacyDatabase {
238- Section {
239- Button ( " Restart app to remove v1 database " ) {
240- UserDefaults . standard. set ( true , forKey: " clearV1Index " )
241- exit ( 0 )
242- }
243- #if os(macOS)
244- . buttonStyle( . link)
245- #endif
246- } footer: {
247- Text (
248- " A legacy database is still present. If the app is functioning correctly, it is safe to manually delete this database. In order to do this, the app needs to be restarted. "
249- )
250- } . disabled ( performingDatabaseMaintenance)
251- }
252-
253- if hasMigratedLegacyDatabase {
254- Section {
255- Button ( " Remove v1 database back-up " ) {
256- self . clearMigratedLegacyDatabase ( )
257- }
258- #if os(macOS)
259- . buttonStyle( . link)
260- #endif
261- } footer: {
262- Text (
263- " After a database upgrade, a copy of the old version is retained for a while. This copy may take up a significant amount of storage space. If everything is working as expected, it is safe to remove this back-up. "
264- )
265- } . disabled ( performingDatabaseMaintenance)
266- }
267- }
268- #if os(macOS)
269- . formStyle( . grouped)
270- #endif
271- . task {
272- self . updateDatabaseInfo ( )
273- }
274- . navigationTitle ( " Database maintenance " )
275- #if os(iOS)
276- . navigationBarTitleDisplayMode( . inline)
277- #endif
278- }
279-
280- private func updateDatabaseInfo( ) {
281- self . hasLegacyDatabase = appState. client. hasLegacyDatabase ( )
282- self . hasMigratedLegacyDatabase = appState. client. hasMigratedLegacyDatabase ( )
283- }
284-
285- private func clearMigratedLegacyDatabase( ) {
286- if self . performingDatabaseMaintenance {
287- return
288- }
289- Task {
290- self . performingDatabaseMaintenance = true
291- do {
292- try appState. client. clearMigratedLegacyDatabase ( )
293- }
294- catch {
295- print ( " Cannot clear migrated V1 index: \( error. localizedDescription) " )
296- }
297- self . updateDatabaseInfo ( )
298- self . performingDatabaseMaintenance = false
299- }
300- }
301- }
302-
303208struct AdvancedSettingsView : View {
304209 @Environment ( AppState . self) private var appState
305210 @ObservedObject var userSettings : AppUserSettings
@@ -312,7 +217,7 @@ struct AdvancedSettingsView: View {
312217
313218 #if os(macOS)
314219 @State private var showConfigurationSettings = false
315- @State private var showDatabaseMaintenance = false
220+ @State private var showTroubleshooting = false
316221 #endif
317222
318223 var body : some View {
@@ -542,35 +447,6 @@ struct AdvancedSettingsView: View {
542447 self . cacheText
543448 }
544449
545- Section {
546- Toggle ( " Enable debug logging " , isOn: userSettings. $loggingToFileEnabled)
547- } header: {
548- Text ( " Logging " )
549- } footer: {
550- if appState. userSettings. loggingToFileEnabled {
551- if appState. isLoggingToFile {
552- Text (
553- " The app is logging to a file in the application folder, which you can share with the developers. "
554- )
555- }
556- else {
557- Text (
558- " After restarting the app, the app will write a log file in the application folder, which you can then share with the developers. "
559- )
560- }
561- }
562- else {
563- if appState. isLoggingToFile {
564- Text ( " Restart the app to stop logging. " )
565- }
566- else {
567- Text (
568- " Logging slows down the app and uses more battery. Only enable it if you are experiencing problems. "
569- )
570- }
571- }
572- }
573-
574450 #if os(iOS)
575451 Section {
576452 ExportButtonView ( )
@@ -585,19 +461,19 @@ struct AdvancedSettingsView: View {
585461
586462 #if os(macOS)
587463 Section {
588- Button ( " Database maintenance " ) {
589- self . showDatabaseMaintenance = true
464+ Button ( " Troubleshooting " ) {
465+ self . showTroubleshooting = true
590466 }
591467 } . buttonStyle ( . link)
592- . sheet ( isPresented: $showDatabaseMaintenance ) {
468+ . sheet ( isPresented: $showTroubleshooting ) {
593469 NavigationStack {
594- DatabaseMaintenanceView ( )
470+ TroubleshootingView ( userSettings : userSettings )
595471 . toolbar ( content: {
596472 ToolbarItem (
597473 placement: . confirmationAction,
598474 content: {
599475 Button ( " Close " ) {
600- showDatabaseMaintenance = false
476+ showTroubleshooting = false
601477 }
602478 } )
603479 } )
@@ -622,8 +498,8 @@ struct AdvancedSettingsView: View {
622498 } )
623499 }
624500 #else
625- NavigationLink ( destination: DatabaseMaintenanceView ( ) ) {
626- Text ( " Database maintenance " )
501+ NavigationLink ( destination: TroubleshootingView ( userSettings : userSettings ) ) {
502+ Label ( " Troubleshooting " , systemImage : " book.and.wrench " )
627503 }
628504 #endif
629505 }
@@ -1130,8 +1006,14 @@ private struct BandwidthSettingsView: View {
11301006 }
11311007
11321008 Section {
1133- NavigationLink ( " About this app " ) {
1134- AboutView ( )
1009+ #if os(iOS)
1010+ NavigationLink ( destination: SupportView ( ) ) {
1011+ Label ( " Questions, support & feedback " , systemImage: " lifepreserver " )
1012+ }
1013+ #endif
1014+
1015+ NavigationLink ( destination: AboutView ( ) ) {
1016+ Label ( " About this app " , systemImage: " info.circle " )
11351017 }
11361018 }
11371019 }
0 commit comments