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[path] != null &&
197
+ this.__pendingCalls[pendingCallId] != null &&
196
198
  Object.keys(body).length === 0
197
199
  ) {
198
- this.__debug(`Reusing pending call ${operationId}`);
199
- const result = await this.__pendingCalls[path];
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
- this.__pendingCalls[path] = (async () => {
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
- })().finally(() => {
221
- delete this.__pendingCalls[path];
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 this.__pendingCalls[path];
237
+ const result = await pendingCall;
225
238
 
226
239
  return result;
227
240
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "homey-api",
3
- "version": "3.0.14",
3
+ "version": "3.0.15",
4
4
  "description": "Homey API",
5
5
  "main": "index.js",
6
6
  "files": [