@@ -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}
0 commit comments