Skip to content

Commit 06e9468

Browse files
committed
chore: Add an option to reset the app state into the app settings (trying to debug potential OOBE issues, no of which are yet reproducible)
1 parent d1e221d commit 06e9468

File tree

3 files changed

+67
-2
lines changed

3 files changed

+67
-2
lines changed

jockey/Info.plist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
</dict>
3131
</array>
3232
<key>CFBundleVersion</key>
33-
<string>ab579ea</string>
33+
<string>a3712c4</string>
3434
<key>LSApplicationCategoryType</key>
3535
<string>public.app-category.utilities</string>
3636
<key>LSMinimumSystemVersion</key>

jockey/SMBShareManager.swift

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
import Foundation
99
import Combine
10+
import AppKit
1011

1112
final class SMBShareManager: ObservableObject {
1213
struct SMBShare: Identifiable, Codable {
@@ -434,6 +435,38 @@ final class SMBShareManager: ObservableObject {
434435
startMonitoring()
435436
}
436437

438+
/// Resets the application state to simulate a fresh installation.
439+
/// Use this during development to test the Out-Of-Box Experience (OOBE).
440+
func resetAppState() {
441+
// Clear all shares
442+
shares.removeAll()
443+
444+
// Clear all reconnection logs
445+
reconnectionLogs.removeAll()
446+
447+
// Reset polling interval to default
448+
pollingInterval = 30
449+
450+
// Clear UserDefaults for all keys
451+
UserDefaults.standard.removeObject(forKey: saveKey)
452+
UserDefaults.standard.removeObject(forKey: pollingIntervalKey)
453+
UserDefaults.standard.removeObject(forKey: reconnectionLogsKey)
454+
UserDefaults.standard.removeObject(forKey: "defaultMountPath")
455+
456+
// Save the cleared state
457+
saveShares()
458+
savePollingInterval()
459+
saveReconnectionLogs()
460+
461+
// Restart monitoring with default interval
462+
startMonitoring()
463+
464+
logInfo("App state has been reset to simulate a fresh installation")
465+
466+
// Quit the application
467+
NSApplication.shared.terminate(nil)
468+
}
469+
437470
func getSystemSMBShares() -> [String: URL] {
438471
// Get list of SMB shares from system
439472
var systemShares: [String: URL] = [:]

jockey/SettingsView.swift

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ struct SettingsView: View {
4040
Label("Settings", systemImage: "gear")
4141
}
4242
}
43-
.frame(width: 500, height: 400)
43+
.frame(width: 500, height: 500)
4444
.onAppear {
4545
refreshSystemShares()
4646
pollingInterval = shareManager.pollingInterval
@@ -316,8 +316,40 @@ struct SettingsView: View {
316316
}
317317
}
318318

319+
VStack(alignment: .leading, spacing: 8) {
320+
Text("Reset")
321+
.font(.subheadline)
322+
.bold()
323+
324+
Text("Reset the app to its initial state, removing all shares and settings.")
325+
.font(.caption)
326+
.foregroundColor(.secondary)
327+
328+
Button("Reset App State") {
329+
// Show confirmation alert
330+
let alert = NSAlert()
331+
alert.messageText = "Reset App State"
332+
alert.informativeText = "This will reset the app to its initial state, removing all shares and settings. THE APP WILL QUIT AFTER RESET. Are you sure you want to continue?"
333+
alert.alertStyle = .warning
334+
alert.addButton(withTitle: "Reset")
335+
alert.addButton(withTitle: "Cancel")
336+
337+
let response = alert.runModal()
338+
if response == .alertFirstButtonReturn {
339+
shareManager.resetAppState()
340+
// Update UI state
341+
pollingInterval = shareManager.pollingInterval
342+
defaultMountPath = "/Volumes"
343+
refreshSystemShares()
344+
}
345+
}
346+
.foregroundColor(.red)
347+
}
348+
319349
Spacer()
320350

351+
Divider()
352+
321353
VStack(alignment: .leading) {
322354
Text("About Jockey")
323355
.font(.subheadline)

0 commit comments

Comments
 (0)