@@ -63,7 +63,7 @@ struct QueueView: View {
6363 @EnvironmentObject var logsCollector : LogsCollector
6464
6565 @State fileprivate var alert : AlertIdentifier ?
66- @State var packageURLs : [ Package ] = [ ]
66+ @State var packages : [ Package ] = [ ]
6767 @State private var selection : Set < UUID > = [ ]
6868
6969 @State var isInDropArea : Bool = false
@@ -83,7 +83,7 @@ struct QueueView: View {
8383 } . padding ( )
8484
8585 List ( selection: $selection) {
86- ForEach ( packageURLs , id: \. id) { package in
86+ ForEach ( packages , id: \. id) { package in
8787 HStack {
8888 Image ( systemName: " shippingbox " )
8989 Text ( " \( package . title_id ?? package . url. lastPathComponent) " )
@@ -106,10 +106,17 @@ struct QueueView: View {
106106 if let url = object, url. pathExtension == " pkg " {
107107 let packageDetails = SFOExplorer ( ) . getParamSFOData ( url: url)
108108 var title : String ?
109+
109110 if let packageDetails = packageDetails {
110111 title = packageDetails [ " TITLE " ]
112+ if let title = title {
113+ logsCollector. addLog ( " Package name defined: \" \( title) \" ( \" \( url) \" ) " )
114+ } else {
115+ logsCollector. addLog ( " Package name for ( \" \( url) \" ) is undefined. Maybe the package is damaged or not compatible with the PS4 system. " )
116+ }
111117 }
112- packageURLs. append ( Package ( url: url, title_id: title) )
118+
119+ packages. append ( Package ( url: url, title_id: title) )
113120 }
114121 }
115122 }
@@ -123,7 +130,7 @@ struct QueueView: View {
123130 Image ( systemName: " shippingbox " )
124131 . resizable ( )
125132 . frame ( width: 100 , height: 100 )
126- Text ( # "Drop " .pkg" files"# )
133+ Text ( " Drop .pkg files " )
127134 . font ( . title)
128135 }
129136 . opacity ( 0.5 )
@@ -172,29 +179,29 @@ struct QueueView: View {
172179 }
173180
174181 private func deleteSelection( ) {
175- packageURLs . removeAll { selection. contains ( $0. id) }
182+ packages . removeAll { selection. contains ( $0. id) }
176183 selection. removeAll ( )
177184 }
178185
179186 fileprivate func AddButton( ) -> ColorButton {
180187 return ColorButton ( text: " Add " , color: . orange, image: Image ( systemName: " plus.rectangle.on.rectangle " ) , action: {
181- let packages = selectPackages ( )
182- for package in packages {
188+ let selectedPackages = selectPackages ( )
189+ for package in selectedPackages {
183190 if let package = package {
184191 let packageDetails = SFOExplorer ( ) . getParamSFOData ( url: package )
185192 var title : String ?
186193 if let packageDetails = packageDetails {
187194 title = packageDetails [ " TITLE " ]
188195 }
189- packageURLs . append ( Package ( url: package , title_id: title) )
196+ packages . append ( Package ( url: package , title_id: title) )
190197 }
191198 }
192199 } )
193200 }
194201
195202 fileprivate func SendButton( ) -> ColorButton {
196203 return ColorButton ( text: " Send " , color: . green, image: Image ( systemName: " arrow.up.forward.app " ) , action: {
197- if packageURLs . isEmpty { return }
204+ if packages . isEmpty { return }
198205
199206 if connection. serverIP. isEmpty || connection. serverPort. isEmpty {
200207 connection. generateServerDetails ( )
@@ -214,13 +221,13 @@ struct QueueView: View {
214221
215222 loadingScreenIsShown = true
216223 DispatchQueue . global ( qos: . background) . async {
217- for index in packageURLs . indices {
218- if packageURLs [ index] . state == . sendSuccess {
224+ for index in packages . indices {
225+ if packages [ index] . state == . sendSuccess {
219226 continue
220227 }
221- let alias = createTempDirPackageAlias ( package : packageURLs [ index] ) !
228+ let alias = createTempDirPackageAlias ( package : packages [ index] ) !
222229
223- logsCollector. addLog ( " Creating package alias ( \" \( packageURLs [ index] . url. path) \" -> \" \( tempDirectory. path) / \( alias) \" ). " )
230+ logsCollector. addLog ( " Creating package alias ( \" \( packages [ index] . url. path) \" -> \" \( tempDirectory. path) / \( alias) \" ). " )
224231 logsCollector. addLog ( " Sending package \" \( alias) \" to the console (IP: \( connection. consoleIP) , Port: \( connection. consolePort) ) " )
225232
226233 let response = sendPackagesToConsole ( packageFilename: alias, connection: connection)
@@ -234,15 +241,15 @@ struct QueueView: View {
234241 }
235242 break
236243 } else if let response = response as? SendSuccess {
237- logsCollector. addLog ( " Successfully sent \( packageURLs [ index] . url) [Package Link: \" \( packageURLs [ index] . id) .pkg \" , id: \( response. taskID) , title: \" \( response. title) \" ] " )
244+ logsCollector. addLog ( " Successfully sent \( packages [ index] . url) [Package Link: \" \( packages [ index] . id) .pkg \" , id: \( response. taskID) , title: \" \( response. title) \" ] " )
238245 DispatchQueue . main. async {
239- packageURLs [ index] . state = . sendSuccess
240- packageURLs [ index] . task_id = response. taskID
246+ packages [ index] . state = . sendSuccess
247+ packages [ index] . task_id = response. taskID
241248 }
242249 } else if let response = response as? SendFailure {
243- logsCollector. addLog ( " An error occurred while sending \( packageURLs [ index] . url) [ \( packageURLs [ index] . id) .pkg] {ERROR: \( response. error) } " )
250+ logsCollector. addLog ( " An error occurred while sending \( packages [ index] . url) [ \( packages [ index] . id) .pkg] {ERROR: \( response. error) } " )
244251 DispatchQueue . main. async {
245- packageURLs [ index] . state = . sendFailure
252+ packages [ index] . state = . sendFailure
246253 }
247254 break
248255 }
@@ -267,7 +274,7 @@ struct QueueView_Previews: PreviewProvider {
267274 @EnvironmentObject var connection : ConnectionDetails
268275
269276 static var previews : some View {
270- let view = QueueView ( packageURLs : [
277+ let view = QueueView ( packages : [
271278 Package ( url: URL ( string: " https://example.com/game.pkg " ) !) ,
272279 Package ( url: URL ( string: " https://example.com/dlc.pkg " ) !, state: . sendSuccess) ,
273280 Package ( url: URL ( string: " https://example.com/dlc.pkg " ) !, state: . sendFailure)
0 commit comments