mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-27 01:43:22 +00:00
Merge pull request #3325 from mkllnk/2469-fix-async-js-requests
2469 Fix async js requests
This commit is contained in:
@@ -9,4 +9,4 @@ angular.module("admin.indexUtils").factory 'Dereferencer', ->
|
||||
dereferenceAttr: (array, attr, data)->
|
||||
if array
|
||||
for object in array
|
||||
object[attr] = data[object[attr].id] unless object[attr] == null
|
||||
object[attr] = data[object[attr].id] if object[attr]
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
angular.module("admin.indexUtils").factory 'RequestMonitor', ($q) ->
|
||||
new class RequestMonitor
|
||||
loadQueue: $q.when([])
|
||||
loadId: 0
|
||||
requestCount: 0
|
||||
loading: false
|
||||
|
||||
load: (promise) ->
|
||||
loadId = (@loadId += 1)
|
||||
@requestCount += 1
|
||||
@loading = true
|
||||
@loadQueue = $q.all([@loadQueue, promise]).then =>
|
||||
@loading = false if @loadId == loadId
|
||||
@requestCount -= 1
|
||||
@loading = false if @requestCount == 0
|
||||
|
||||
Reference in New Issue
Block a user