@reactoo/watchtogether-sdk-js 2.7.64 → 2.7.65

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reactoo/watchtogether-sdk-js",
3
- "version": "2.7.64",
3
+ "version": "2.7.65",
4
4
  "description": "Javascript SDK for Reactoo",
5
5
  "main": "dist/watchtogether-sdk.min.js",
6
6
  "module": "dist/watchtogether-sdk.min.js",
package/src/models/iot.js CHANGED
@@ -182,24 +182,28 @@ let iot = function () {
182
182
  if(!__currentTopics.has(topic)) {
183
183
  __currentTopics.add(topic);
184
184
  if(!this.iot.__promise) return Promise.reject('not_connected');
185
- // if subscription fails, remove the topic from the current topics
186
185
  return this.iot.__promise
187
186
  .then(() => this.__privates.iot.subscribe(topic))
188
187
  .catch((error) => {
189
188
 
189
+ // if subscription fails, remove the topic from the current topics
190
190
  __currentTopics.delete(topic);
191
191
 
192
192
  if(error?.cause === -1) {
193
193
  return Promise.reject('invalid_topic');
194
194
  }
195
195
 
196
+ if(!shouldBeConnected || isReconnecting) {
197
+ return Promise.reject('subscription_failed');
198
+ }
199
+
196
200
  if(shouldBeConnected && !isReconnecting && subscriptionFailureCount > 5) {
197
201
  this.__privates.iot.log('Subscription failure exceeded, reconnecting...');
198
202
  this.iot.__updateCredentials();
199
203
  return Promise.reject('subscription_failed');
200
204
  }
201
- subscriptionFailureCount++;
202
205
 
206
+ subscriptionFailureCount++;
203
207
  return this.subscribe(topic)
204
208
  });
205
209
  }
@@ -208,10 +212,10 @@ let iot = function () {
208
212
  unsubscribe: (topic) => {
209
213
  __currentTopics.delete(topic);
210
214
  if(!this.iot.__promise) return Promise.reject('not_connected');
211
- // if unsubscription fails add the topic back to the current topics
212
215
  return this.iot.__promise
213
216
  .then(() => this.__privates.iot.unsubscribe(topic))
214
217
  .catch(() => {
218
+ // if unsubscription fails add the topic back to the current topics
215
219
  __currentTopics.add(topic);
216
220
  return Promise.reject('unsubscription_failed');
217
221
  });