Skip to content
This repository was archived by the owner on Mar 7, 2026. It is now read-only.

Commit 560448c

Browse files
authored
Add Load Defaults button
1 parent 2ebf1a3 commit 560448c

3 files changed

Lines changed: 37 additions & 26 deletions

File tree

Sources/prostore/viewModelsAndHelpers/SourcesViewModel.swift

Lines changed: 29 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,17 @@ class SourcesViewModel: ObservableObject {
1010

1111
private let fileURL: URL
1212

13+
private let defaultSourceURLs = [
14+
"https://repository.apptesters.org/",
15+
"https://wuxu1.github.io/wuxu-complete.json",
16+
"https://wuxu1.github.io/wuxu-complete-plus.json",
17+
"https://raw.githubusercontent.com/swaggyP36000/TrollStore-IPAs/main/apps_esign.json",
18+
"https://ipa.cypwn.xyz/cypwn.json",
19+
"https://quarksources.github.io/dist/quantumsource.min.json",
20+
"https://quarksources.github.io/dist/quantumsource%2B%2B.min.json",
21+
"https://raw.githubusercontent.com/Neoncat-OG/TrollStore-IPAs/main/apps_esign.json"
22+
]
23+
1324
enum ValidationState {
1425
case pending
1526
case loading
@@ -76,17 +87,7 @@ class SourcesViewModel: ObservableObject {
7687
self.sources = decoded
7788
} else {
7889
// Load default sources
79-
let defaultSources = [
80-
"https://repository.apptesters.org/",
81-
"https://wuxu1.github.io/wuxu-complete.json",
82-
"https://wuxu1.github.io/wuxu-complete-plus.json",
83-
"https://raw.githubusercontent.com/swaggyP36000/TrollStore-IPAs/main/apps_esign.json",
84-
"https://ipa.cypwn.xyz/cypwn.json",
85-
"https://quarksources.github.io/dist/quantumsource.min.json",
86-
"https://quarksources.github.io/dist/quantumsource%2B%2B.min.json",
87-
"https://raw.githubusercontent.com/Neoncat-OG/TrollStore-IPAs/main/apps_esign.json"
88-
]
89-
self.sources = defaultSources.map { Source(urlString: $0) }
90+
self.sources = defaultSourceURLs.map { Source(urlString: $0) }
9091
saveSources()
9192
}
9293
} catch {
@@ -96,17 +97,7 @@ class SourcesViewModel: ObservableObject {
9697
}
9798

9899
func loadDefaultSources() {
99-
let defaultSources = [
100-
"https://repository.apptesters.org/",
101-
"https://wuxu1.github.io/wuxu-complete.json",
102-
"https://wuxu1.github.io/wuxu-complete-plus.json",
103-
"https://raw.githubusercontent.com/swaggyP36000/TrollStore-IPAs/main/apps_esign.json",
104-
"https://ipa.cypwn.xyz/cypwn.json",
105-
"https://quarksources.github.io/dist/quantumsource.min.json",
106-
"https://quarksources.github.io/dist/quantumsource%2B%2B.min.json",
107-
"https://raw.githubusercontent.com/Neoncat-OG/TrollStore-IPAs/main/apps_esign.json"
108-
]
109-
self.sources = defaultSources.map { Source(urlString: $0) }
100+
self.sources = defaultSourceURLs.map { Source(urlString: $0) }
110101
saveSources()
111102
}
112103

@@ -179,7 +170,6 @@ class SourcesViewModel: ObservableObject {
179170
}
180171

181172
func validateSource(_ source: Source) {
182-
// Always set to loading first
183173
validationStates[source.urlString] = .loading
184174

185175
guard let url = source.url else {
@@ -214,4 +204,20 @@ class SourcesViewModel: ObservableObject {
214204
func getSourcesURLs() -> [URL] {
215205
sources.compactMap { $0.url }
216206
}
207+
208+
// MARK: - New method to add default sources without duplicates
209+
func addDefaultSourcesIfNeeded() {
210+
var added = false
211+
for defaultURL in defaultSourceURLs {
212+
if !sources.contains(where: { $0.urlString.caseInsensitiveCompare(defaultURL) == .orderedSame }) {
213+
let newSource = Source(urlString: defaultURL)
214+
sources.append(newSource)
215+
added = true
216+
}
217+
}
218+
if added {
219+
saveSources()
220+
validateAllSources()
221+
}
222+
}
217223
}

Sources/prostore/views/SourcesManagerView.swift

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// Replace existing SourcesManagerView with this
21
import SwiftUI
32

43
struct SourcesManagerView: View {
@@ -120,6 +119,12 @@ struct SourcesManagerView: View {
120119
Image(systemName: "arrow.clockwise")
121120
}
122121
}
122+
123+
ToolbarItem(placement: .navigationBarLeading) {
124+
Button("Load Defaults") {
125+
sourcesViewModel.addDefaultSourcesIfNeeded()
126+
}
127+
}
123128
}
124129
.onAppear {
125130
sourcesViewModel.validateAllSources()

project.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ targets:
3636
properties:
3737
CFBundleDisplayName: "ProStore"
3838
CFBundleName: "prostore"
39-
CFBundleVersion: "65"
40-
CFBundleShortVersionString: "1.2.3"
39+
CFBundleVersion: "66"
40+
CFBundleShortVersionString: "1.2.4"
4141
UILaunchStoryboardName: "LaunchScreen"
4242
NSPrincipalClass: "UIApplication"
4343
NSAppTransportSecurity:

0 commit comments

Comments
 (0)