@@ -53,6 +53,8 @@ - (id)init {
5353 self.taskQueue = [[NSOperationQueue alloc ] init ];
5454 self.taskQueue .qualityOfService = NSQualityOfServiceUtility ;
5555 self.taskQueue .maxConcurrentOperationCount = 10 ;
56+ self.rebindProgressDict = [NSMutableDictionary dictionary ];
57+ self.rebindUploadProgressDict = [NSMutableDictionary dictionary ];
5658 }
5759
5860 return self;
@@ -87,14 +89,33 @@ - (void) sendRequest:(__weak NSDictionary * _Nullable )options
8789
8890 @synchronized ([RNFetchBlobNetwork class ]) {
8991 [self .requestsTable setObject: request forKey: taskId];
92+ [self checkProgressConfig ];
9093 }
9194}
9295
96+ - (void ) checkProgressConfig {
97+ // reconfig progress
98+ [self .rebindProgressDict enumerateKeysAndObjectsUsingBlock: ^(NSString * _Nonnull key, RNFetchBlobProgress * _Nonnull config, BOOL * _Nonnull stop) {
99+ [self enableProgressReport: key config: config];
100+ }];
101+ [self .rebindProgressDict removeAllObjects ];
102+
103+ // reconfig uploadProgress
104+ [self .rebindUploadProgressDict enumerateKeysAndObjectsUsingBlock: ^(NSString * _Nonnull key, RNFetchBlobProgress * _Nonnull config, BOOL * _Nonnull stop) {
105+ [self enableUploadProgress: key config: config];
106+ }];
107+ [self .rebindUploadProgressDict removeAllObjects ];
108+ }
109+
93110- (void ) enableProgressReport : (NSString *) taskId config : (RNFetchBlobProgress *)config
94111{
95112 if (config) {
96113 @synchronized ([RNFetchBlobNetwork class ]) {
97- [self .requestsTable objectForKey: taskId].progressConfig = config;
114+ if (![self .requestsTable objectForKey: taskId]) {
115+ [self .rebindProgressDict setValue: config forKey: taskId];
116+ } else {
117+ [self .requestsTable objectForKey: taskId].progressConfig = config;
118+ }
98119 }
99120 }
100121}
@@ -103,7 +124,11 @@ - (void) enableUploadProgress:(NSString *) taskId config:(RNFetchBlobProgress *)
103124{
104125 if (config) {
105126 @synchronized ([RNFetchBlobNetwork class ]) {
106- [self .requestsTable objectForKey: taskId].uploadProgressConfig = config;
127+ if (![self .requestsTable objectForKey: taskId]) {
128+ [self .rebindUploadProgressDict setValue: config forKey: taskId];
129+ } else {
130+ [self .requestsTable objectForKey: taskId].uploadProgressConfig = config;
131+ }
107132 }
108133 }
109134}
0 commit comments