Skip to content

Commit 2bdbefc

Browse files
committed
ui: improve support options view
1 parent e232397 commit 2bdbefc

File tree

8 files changed

+729
-141
lines changed

8 files changed

+729
-141
lines changed

Localizable.xcstrings

Lines changed: 481 additions & 0 deletions
Large diffs are not rendered by default.

Sushitrain.xcodeproj/project.pbxproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@
6363
65F15BFD2CA03DCE00E13DDD /* SushitrainCore.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = 65AE125A2C3AB03E00E721D4 /* SushitrainCore.xcframework */; };
6464
65F15C012CA06B2300E13DDD /* UploadsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 65F15C002CA06B2100E13DDD /* UploadsView.swift */; };
6565
65F15C032CA1F85E00E13DDD /* SafariView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 65F15C022CA1F85D00E13DDD /* SafariView.swift */; };
66+
65F7EFF72E5F58B8008A64E0 /* SupportView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 65F7EFF62E5F58B5008A64E0 /* SupportView.swift */; };
6667
65F825EC2CAF1E0900564F57 /* AddressesView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 65F825EB2CAF1E0600564F57 /* AddressesView.swift */; };
6768
/* End PBXBuildFile section */
6869

@@ -150,6 +151,7 @@
150151
65F15BFB2CA03CBA00E13DDD /* BackgroundManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BackgroundManager.swift; sourceTree = "<group>"; };
151152
65F15C002CA06B2100E13DDD /* UploadsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UploadsView.swift; sourceTree = "<group>"; };
152153
65F15C022CA1F85D00E13DDD /* SafariView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SafariView.swift; sourceTree = "<group>"; };
154+
65F7EFF62E5F58B5008A64E0 /* SupportView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SupportView.swift; sourceTree = "<group>"; };
153155
65F825EB2CAF1E0600564F57 /* AddressesView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AddressesView.swift; sourceTree = "<group>"; };
154156
/* End PBXFileReference section */
155157

@@ -237,6 +239,7 @@
237239
653359C82D8EAF3A005CCA43 /* Settings.bundle */,
238240
652763BA2C45C99200250D3C /* SettingsView.swift */,
239241
65C9E14B2C3F341F00EDCE6C /* StartView.swift */,
242+
65F7EFF62E5F58B5008A64E0 /* SupportView.swift */,
240243
65C9E1462C3DB67C00EDCE6C /* Sushitrain.entitlements */,
241244
65A3D2212CCEEEA200117501 /* ThumbnailImage.swift */,
242245
6505643E2CA98D1F009FFFB9 /* ThumbnailView.swift */,
@@ -387,6 +390,7 @@
387390
6510F19E2DAA52CF003E4D3C /* FolderSettings.swift in Sources */,
388391
6596E2422E04ABD70069B31C /* DownloadsView.swift in Sources */,
389392
6505643F2CA98D22009FFFB9 /* ThumbnailView.swift in Sources */,
393+
65F7EFF72E5F58B8008A64E0 /* SupportView.swift in Sources */,
390394
6551053C2D7D8F8E00F96814 /* BrowserListView.swift in Sources */,
391395
6550DFE82D6A645300D8DCC9 /* EncryptionView.swift in Sources */,
392396
654A7E602DF5966C008DF794 /* BrowserWebView.swift in Sources */,

Sushitrain/AboutView.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,6 @@ struct AboutView: View {
2929
string:
3030
"https://www.apple.com/legal/internet-services/itunes/dev/stdeula/"
3131
)!)
32-
Link("Frequently asked questions", destination: URL(string: "https://t-shaped.nl/synctrain-support")!)
33-
Link("Ask a question", destination: URL(string: "https://github.com/pixelspark/sushitrain/discussions")!)
3432
}
3533

3634
Section("Open source") {

Sushitrain/App.swift

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,16 @@ struct SushitrainApp: App {
192192
Toggle("Hide dotfiles", isOn: appState.userSettings.$dotFilesHidden)
193193
}
194194

195+
CommandGroup(replacing: CommandGroupPlacement.help) {
196+
Button(
197+
action: {
198+
openWindow(id: "support")
199+
},
200+
label: {
201+
Text("Questions, support & feedback...")
202+
})
203+
}
204+
195205
CommandGroup(replacing: CommandGroupPlacement.appInfo) {
196206
Button(
197207
action: {
@@ -231,6 +241,14 @@ struct SushitrainApp: App {
231241
}
232242
.windowResizability(.contentSize)
233243

244+
// Support window
245+
Window("Questions, support & feedback", id: "support") {
246+
NavigationStack {
247+
SupportView()
248+
}.environment(appState)
249+
}
250+
.windowResizability(.contentSize)
251+
234252
MenuBarExtraView(hideInDock: $hideInDock)
235253
.environment(appState)
236254

Sushitrain/FolderView.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ struct FolderStatusDescription {
207207
struct FolderStatusView: View {
208208
@Environment(AppState.self) private var appState
209209
var folder: SushitrainFolder
210-
210+
211211
@State private var statistics: SushitrainFolderStats? = nil
212212
@State private var status: String? = nil
213213
@State private var folderStatusDescription: FolderStatusDescription? = nil
@@ -220,7 +220,7 @@ struct FolderStatusView: View {
220220
let formatter = ByteCountFormatter()
221221
if let globalBytes = statistics.global?.bytes, let localBytes = statistics.local?.bytes {
222222
let remainingText = formatter.string(fromByteCount: (globalBytes - localBytes))
223-
223+
224224
ProgressView(
225225
value: Double(localBytes) / Double(globalBytes),
226226
total: 1.0
@@ -243,7 +243,7 @@ struct FolderStatusView: View {
243243
else {
244244
self.statusLabel()
245245
}
246-
246+
247247
if let folderStatus = self.folderStatusDescription, let txt = folderStatus.additionalText {
248248
Text(txt).foregroundStyle(.red)
249249
}
@@ -259,7 +259,7 @@ struct FolderStatusView: View {
259259
}
260260
}
261261
}
262-
262+
263263
private func update() async {
264264
var error: NSError? = nil
265265
self.status = folder.state(&error)

Sushitrain/SettingsView.swift

Lines changed: 16 additions & 134 deletions
Original file line numberDiff line numberDiff line change
@@ -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-
303208
struct 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
}

Sushitrain/StartView.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -543,7 +543,7 @@ struct StartView: View {
543543
if $0.isPaused() {
544544
return false
545545
}
546-
546+
547547
if let d = $0.lastSeen()?.date() {
548548
return -d.timeIntervalSinceNow > appState.userSettings.longTimeNoSeeInterval
549549
}

0 commit comments

Comments
 (0)