chat4app-client-angular 1.0.11 → 1.0.13

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.
@@ -2228,8 +2228,6 @@
2228
2228
  chatCallback.onChatClosed(chat4appMessage);
2229
2229
  }
2230
2230
  else if (data.type == "count_notread") {
2231
- console.log("count_notread");
2232
- console.log(data);
2233
2231
  var chat4appMessage = new Chat4AppMessageReceive();
2234
2232
  chat4appMessage.data.chatId = data.chatId;
2235
2233
  chat4appMessage.data.chatMessageId = data.chatMessageId;
@@ -2247,7 +2245,7 @@
2247
2245
  chatCallback.onCountNotRead(chat4appMessage);
2248
2246
  }
2249
2247
  };
2250
- Chat4appClientAngularService.prototype.ensureConn = function (chatUserExternalId) {
2248
+ Chat4appClientAngularService.prototype.ensureConn = function (chatUserExternalId, forceReconnectNats) {
2251
2249
  return __awaiter(this, void 0, void 0, function () {
2252
2250
  var that, uriStep1, server, _b;
2253
2251
  return __generator(this, function (_c) {
@@ -2264,13 +2262,16 @@
2264
2262
  if (this.debug) {
2265
2263
  console.log("ws server: " + server);
2266
2264
  }
2267
- if (!(!this.nc || (this.nc.isClose && this.nc.isClose()))) return [3 /*break*/, 2];
2265
+ if (!(forceReconnectNats || !this.nc || (this.nc.isClose && this.nc.isClose()))) return [3 /*break*/, 3];
2266
+ return [4 /*yield*/, that.disconnectInternal(true)];
2267
+ case 1:
2268
+ _c.sent();
2268
2269
  _b = that;
2269
2270
  return [4 /*yield*/, nats_min.connect({ url: server, user: chatUserExternalId, pass: this.getBearerToken(), reconnect: false })];
2270
- case 1:
2271
- _b.nc = _c.sent();
2272
- _c.label = 2;
2273
2271
  case 2:
2272
+ _b.nc = _c.sent();
2273
+ _c.label = 3;
2274
+ case 3:
2274
2275
  this.chatUserExternalId = chatUserExternalId;
2275
2276
  return [2 /*return*/, that.nc];
2276
2277
  }
@@ -2278,6 +2279,13 @@
2278
2279
  });
2279
2280
  };
2280
2281
  Chat4appClientAngularService.prototype.disconnect = function () {
2282
+ return __awaiter(this, void 0, void 0, function () {
2283
+ return __generator(this, function (_b) {
2284
+ return [2 /*return*/, this.disconnectInternal(false)];
2285
+ });
2286
+ });
2287
+ };
2288
+ Chat4appClientAngularService.prototype.disconnectInternal = function (ignoreOffLine) {
2281
2289
  return __awaiter(this, void 0, void 0, function () {
2282
2290
  var e_1;
2283
2291
  var _this = this;
@@ -2292,7 +2300,7 @@
2292
2300
  catch (e) {
2293
2301
  }
2294
2302
  }
2295
- if (this.nc && this.chatUserExternalId && this.chatUserExternalId.length > 0 && this.getBearerToken() && this.getBearerToken().length > 0) {
2303
+ if (!ignoreOffLine && this.nc && this.chatUserExternalId && this.chatUserExternalId.length > 0 && this.getBearerToken() && this.getBearerToken().length > 0) {
2296
2304
  this.setOffLine(this.chatUserExternalId).subscribe(function () {
2297
2305
  if (_this.debug) {
2298
2306
  console.log("had set offline");
@@ -2369,7 +2377,7 @@
2369
2377
  switch (_b.label) {
2370
2378
  case 0:
2371
2379
  that = this;
2372
- this.disconnect();
2380
+ this.disconnectInternal(true);
2373
2381
  securityToken = this.getBearerToken();
2374
2382
  tokenAuth = "";
2375
2383
  if (securityToken && securityToken.startsWith("Bearer ")) {
@@ -2407,7 +2415,7 @@
2407
2415
  if (_this.debug) {
2408
2416
  console.log("try reconnect...");
2409
2417
  }
2410
- _this.ensureConn(userId);
2418
+ _this.ensureConn(userId, true);
2411
2419
  }
2412
2420
  }, 1000);
2413
2421
  if (this.debug) {