homey-api 3.0.14 → 3.0.15
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.
|
@@ -189,19 +189,22 @@ class Manager extends EventEmitter {
|
|
|
189
189
|
path = `${path}?${queryString}`;
|
|
190
190
|
}
|
|
191
191
|
|
|
192
|
+
const pendingCallId = `${operationId}::${path}`
|
|
193
|
+
|
|
192
194
|
if (
|
|
193
195
|
operation.method.toLowerCase() === 'get' &&
|
|
194
196
|
$cache === true &&
|
|
195
|
-
this.__pendingCalls[
|
|
197
|
+
this.__pendingCalls[pendingCallId] != null &&
|
|
196
198
|
Object.keys(body).length === 0
|
|
197
199
|
) {
|
|
198
|
-
this.__debug(`Reusing pending call ${
|
|
199
|
-
|
|
200
|
+
this.__debug(`Reusing pending call ${pendingCallId}`);
|
|
201
|
+
|
|
202
|
+
const result = await this.__pendingCalls[pendingCallId];
|
|
200
203
|
|
|
201
204
|
return result;
|
|
202
205
|
}
|
|
203
206
|
|
|
204
|
-
|
|
207
|
+
const pendingCall = (async () => {
|
|
205
208
|
const result = await this.__request({
|
|
206
209
|
$validate,
|
|
207
210
|
$cache,
|
|
@@ -217,11 +220,21 @@ class Manager extends EventEmitter {
|
|
|
217
220
|
});
|
|
218
221
|
|
|
219
222
|
return result;
|
|
220
|
-
})()
|
|
221
|
-
|
|
222
|
-
|
|
223
|
+
})();
|
|
224
|
+
|
|
225
|
+
if (
|
|
226
|
+
operation.method.toLowerCase() === 'get' &&
|
|
227
|
+
$cache === true &&
|
|
228
|
+
this.__pendingCalls[pendingCallId] == null &&
|
|
229
|
+
Object.keys(body).length === 0
|
|
230
|
+
) {
|
|
231
|
+
this.__pendingCalls[pendingCallId] = pendingCall;
|
|
232
|
+
this.__pendingCalls[pendingCallId].finally(() => {
|
|
233
|
+
delete this.__pendingCalls[pendingCallId];
|
|
234
|
+
});
|
|
235
|
+
}
|
|
223
236
|
|
|
224
|
-
const result = await
|
|
237
|
+
const result = await pendingCall;
|
|
225
238
|
|
|
226
239
|
return result;
|
|
227
240
|
},
|