diff options
| author | Fuwn <[email protected]> | 2025-03-02 05:30:49 -0800 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2025-03-02 05:30:49 -0800 |
| commit | e4ac457d4f7599f6eb3416b9d4b0c46ee6449c9f (patch) | |
| tree | 14dc358b49317eeee08c7e2d4bdee747ef432cf8 | |
| parent | feat: Development commit (diff) | |
| download | sora-testing-e4ac457d4f7599f6eb3416b9d4b0c46ee6449c9f.tar.xz sora-testing-e4ac457d4f7599f6eb3416b9d4b0c46ee6449c9f.zip | |
feat: Development commit
| -rw-r--r-- | Sora/Data/Settings/SettingsManager.swift | 31 | ||||
| -rw-r--r-- | Sora/Views/Settings/Section/SettingsDebugView.swift | 20 | ||||
| -rw-r--r-- | Sora/Views/Settings/SettingsView.swift | 6 |
3 files changed, 57 insertions, 0 deletions
diff --git a/Sora/Data/Settings/SettingsManager.swift b/Sora/Data/Settings/SettingsManager.swift index 9ffc53b..5b6e967 100644 --- a/Sora/Data/Settings/SettingsManager.swift +++ b/Sora/Data/Settings/SettingsManager.swift @@ -131,4 +131,35 @@ class SettingsManager: ObservableObject { func removeSearchHistoryEntry(withID id: UUID) { searchHistory.removeAll { $0.id == id } } + + #if DEBUG + // https://stackoverflow.com/a/68926484/14452787 + private func randomWord() -> String { + var word = "" + + for _ in 0..<5 { + word += String(format: "%c", Int.random(in: 97..<123)) as String + } + + return word + } + + func addDummyBookmarks() { + for _ in 0..<10 { + let randomTags: [String] = Array(repeating: randomWord(), count: Int.random(in: 1...5)) + + addBookmark(provider: .safebooru, tags: randomTags) + } + } + + func addDummySearchHistory() { + for _ in 0..<10 { + let randomTags: [String] = Array(repeating: randomWord(), count: Int.random(in: 1...5)) + + appendToSearchHistory( + BooruSearchQuery(provider: .safebooru, tags: randomTags, searchedAt: Date()) + ) + } + } + #endif } diff --git a/Sora/Views/Settings/Section/SettingsDebugView.swift b/Sora/Views/Settings/Section/SettingsDebugView.swift new file mode 100644 index 0000000..af55745 --- /dev/null +++ b/Sora/Views/Settings/Section/SettingsDebugView.swift @@ -0,0 +1,20 @@ +import SwiftUI + +struct SettingsDebugView: View { + @EnvironmentObject private var settingsManager: SettingsManager + var body: some View { + Button(action: { settingsManager.addDummyBookmarks() }) { + Text("Add Dummy Bookmarks") + } + #if os(macOS) + .frame(maxWidth: .infinity, alignment: .trailing) + #endif + + Button(action: { settingsManager.addDummySearchHistory() }) { + Text("Add Dummy Search History") + } + #if os(macOS) + .frame(maxWidth: .infinity, alignment: .trailing) + #endif + } +} diff --git a/Sora/Views/Settings/SettingsView.swift b/Sora/Views/Settings/SettingsView.swift index a9c8141..4f00cbd 100644 --- a/Sora/Views/Settings/SettingsView.swift +++ b/Sora/Views/Settings/SettingsView.swift @@ -31,6 +31,12 @@ struct SettingsView: View { #endif } + #if DEBUG + Section(header: Text("Debug")) { + SettingsDebugView() + } + #endif + Section(header: Text("Credits")) { SettingsCreditsView() } |