Skip to content

Commit 8091c21

Browse files
committed
load with id bugfix
1 parent 32882cd commit 8091c21

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/graph/ArSyncStore.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import ArSyncAPI from '../core/ArSyncApi'
22
import { parseRequest } from '../core/parseRequest'
33

44
const ModelBatchRequest = {
5-
timer: null,
5+
timer: null as null | number,
66
apiRequests: {} as {
77
[key: string]: {
88
[queryJSON: string]: {
@@ -28,7 +28,7 @@ const ModelBatchRequest = {
2828
})
2929
},
3030
batchFetch() {
31-
const { apiRequests } = this as typeof ModelBatchRequest
31+
const { apiRequests } = ModelBatchRequest
3232
for (const field in apiRequests) {
3333
const apiRequest = apiRequests[field]
3434
for (const { query, requests } of Object.values(apiRequest)) {
@@ -41,13 +41,13 @@ const ModelBatchRequest = {
4141
})
4242
}
4343
}
44-
this.apiRequests = {}
44+
ModelBatchRequest.apiRequests = {}
4545
},
4646
setTimer() {
47-
if (this.timer) return
48-
this.timer = setTimeout(() => {
49-
this.timer = null
50-
this.batchFetch()
47+
if (ModelBatchRequest.timer) return
48+
ModelBatchRequest.timer = setTimeout(() => {
49+
ModelBatchRequest.timer = null
50+
ModelBatchRequest.batchFetch()
5151
}, 20)
5252
}
5353
}
@@ -100,7 +100,7 @@ class ArSyncContainerBase {
100100
static _load({ field, id, params, query }, root) {
101101
const parsedQuery = parseRequest(query, true)
102102
if (id) {
103-
return ModelBatchRequest.fetch(field, query, id).then(data => new ArSyncRecord(parsedQuery, data[0], null, root))
103+
return ModelBatchRequest.fetch(field, query, id).then(data => new ArSyncRecord(parsedQuery, data, null, root))
104104
} else {
105105
const request = { field, query, params }
106106
return ArSyncAPI.syncFetch(request).then((response: any) => {

0 commit comments

Comments
 (0)