@takeoffmedia/react-native-penthera 0.2.29 → 0.2.30

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -17,6 +17,7 @@ class Penthera: RCTEventEmitter, VirtuosoDownloadEngineNotificationsDelegate {
17
17
  var headroom: Int64 = 1024 * 1024 // 1 GB = 1024 MB
18
18
  var maxStorageAllowed: Int64 = 20 * 1024 * 1024 // 20 GB = 20480 MB
19
19
  var minimumLowBandWidth: Double = 500 // 500 kbps
20
+ var assetError: String = ""
20
21
 
21
22
  func updateStatusInfo() {
22
23
  DispatchQueue.global().async {
@@ -152,15 +153,17 @@ class Penthera: RCTEventEmitter, VirtuosoDownloadEngineNotificationsDelegate {
152
153
 
153
154
  public func downloadEngineDidStartDownloadingAsset(_ asset: VirtuosoAsset) {
154
155
  self.currentAset = asset
156
+ self.assetError = ""
155
157
  updateStatusInfo()
156
158
  EventEmitter.sharedInstance.dispatch(name: "penthera", code: PentheraEvent.DID_START_DOWNLOADING, assetId: asset.assetID, body: "")
157
159
  }
158
160
 
159
161
 
160
162
  public func downloadEngineProgressUpdated(for asset: VirtuosoAsset) {
163
+ var status = self.downloadEngineNotifications
161
164
  updateStatusInfo()
162
165
  let percentage: Float = Float(asset.fractionComplete)/Float(asset.estimatedSize)
163
- if(percentage.isFinite) {
166
+ if(percentage.isFinite && self.assetError.isEmpty ) {
164
167
  EventEmitter.sharedInstance.dispatch(name: "penthera", code: PentheraEvent.PROGRESS_UPDATED, assetId: asset.assetID, body: "\(Int(asset.fractionComplete*100))")
165
168
  }
166
169
  }
@@ -179,8 +182,9 @@ class Penthera: RCTEventEmitter, VirtuosoDownloadEngineNotificationsDelegate {
179
182
  }
180
183
 
181
184
  public func downloadEngineDidEncounterError(for asset: VirtuosoAsset, error: Error?, task: URLSessionTask?, data: Data?, statusCode: NSNumber?) {
182
- var eventError = parseErrorRulesPenthera(anyElement: error);
183
- EventEmitter.sharedInstance.dispatch(name: "penthera", code: PentheraEvent.ERROR_DOWNLOAD, assetId: asset.assetID, body: eventError ?? "Error downloading")
185
+ let eventError = parseErrorRulesPenthera(anyElement: error);
186
+ self.assetError = eventError
187
+ EventEmitter.sharedInstance.dispatch(name: "penthera", code: PentheraEvent.ERROR_DOWNLOAD, assetId: asset.assetID, body: eventError )
184
188
  }
185
189
 
186
190
  public func downloadEngineInternalQueueUpdate(asset: VirtuosoAsset) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@takeoffmedia/react-native-penthera",
3
- "version": "0.2.29",
3
+ "version": "0.2.30",
4
4
  "description": "test",
5
5
  "main": "lib/commonjs/index",
6
6
  "module": "lib/module/index",