forked from CIT/Vmeda.Online
		
	Merge pull request #1820 from albertgasset/MOBILE-2915
MOBILE-2915 site: Fix clearing of cached request promises
This commit is contained in:
		
						commit
						c0697e4436
					
				| @ -582,7 +582,7 @@ export class CoreSite { | |||||||
|             }); |             }); | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         let promise = this.getFromCache(method, data, preSets, false, originalData).catch(() => { |         const promise = this.getFromCache(method, data, preSets, false, originalData).catch(() => { | ||||||
|             // Do not pass those options to the core WS factory.
 |             // Do not pass those options to the core WS factory.
 | ||||||
|             return this.wsProvider.call(method, data, wsPreSets).then((response) => { |             return this.wsProvider.call(method, data, wsPreSets).then((response) => { | ||||||
|                 if (preSets.saveToCache) { |                 if (preSets.saveToCache) { | ||||||
| @ -690,14 +690,12 @@ export class CoreSite { | |||||||
|         this.ongoingRequests[cacheId] = promise; |         this.ongoingRequests[cacheId] = promise; | ||||||
| 
 | 
 | ||||||
|         // Clear ongoing request after setting the promise (just in case it's already resolved).
 |         // Clear ongoing request after setting the promise (just in case it's already resolved).
 | ||||||
|         promise = promise.finally(() => { |         return promise.finally(() => { | ||||||
|             // Make sure we don't clear the promise of a newer request that ignores the cache.
 |             // Make sure we don't clear the promise of a newer request that ignores the cache.
 | ||||||
|             if (this.ongoingRequests[cacheId] === promise) { |             if (this.ongoingRequests[cacheId] === promise) { | ||||||
|                 delete this.ongoingRequests[cacheId]; |                 delete this.ongoingRequests[cacheId]; | ||||||
|             } |             } | ||||||
|         }); |         }).then((response) => { | ||||||
| 
 |  | ||||||
|         return promise.then((response) => { |  | ||||||
|             // We pass back a clone of the original object, this may prevent errors if in the callback the object is modified.
 |             // We pass back a clone of the original object, this may prevent errors if in the callback the object is modified.
 | ||||||
|             return this.utils.clone(response); |             return this.utils.clone(response); | ||||||
|         }); |         }); | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user