@chat-leo/chatleolib 2.1.0 → 2.1.1

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/dist/index.js CHANGED
@@ -7556,7 +7556,7 @@ class ChatLeoLib {
7556
7556
  this.clients.delete(client);
7557
7557
  }
7558
7558
  async requestConnection(client, options = {}) {
7559
- var _b, _c, _d, _e, _f, _g;
7559
+ var _b, _c, _d, _e, _f, _g, _h;
7560
7560
  console.debug(`requestConnection`, client, options);
7561
7561
  client.chatStore = this.chatStore;
7562
7562
  this.registerClient(client);
@@ -7573,18 +7573,21 @@ class ChatLeoLib {
7573
7573
  console.debug('Already logged in, hydrate client');
7574
7574
  (_b = client.setLoading) === null || _b === void 0 ? void 0 : _b.call(client, false);
7575
7575
  (_c = client.setLoggedIn) === null || _c === void 0 ? void 0 : _c.call(client, true, this.userProfile);
7576
+ // A client that joins an already-connected session must learn the current
7577
+ // status, or it keeps its initial "disconnected" state (stale Offline banner).
7578
+ (_d = client.setConnectionStatus) === null || _d === void 0 ? void 0 : _d.call(client, this.chatStore.connectionStatus);
7576
7579
  return { status: 'connected' };
7577
7580
  }
7578
7581
  // No active session: allow client to wait without triggering login if no credentials
7579
7582
  const hasCreds = Boolean(options.ticket || (options.username && options.password));
7580
7583
  if (!this.loginPromise && !hasCreds) {
7581
7584
  console.debug('No active session, allow client to wait');
7582
- (_d = client.setLoading) === null || _d === void 0 ? void 0 : _d.call(client, false);
7585
+ (_e = client.setLoading) === null || _e === void 0 ? void 0 : _e.call(client, false);
7583
7586
  return { status: 'waiting' };
7584
7587
  }
7585
7588
  console.debug('Requesting connection');
7586
7589
  // Gate concurrent logins
7587
- (_e = client.setLoading) === null || _e === void 0 ? void 0 : _e.call(client, true);
7590
+ (_f = client.setLoading) === null || _f === void 0 ? void 0 : _f.call(client, true);
7588
7591
  if (!this.loginPromise && hasCreds) {
7589
7592
  // Start a new login process
7590
7593
  this.loginPromise = this.performLogin(options)
@@ -7604,8 +7607,8 @@ class ChatLeoLib {
7604
7607
  catch (err) {
7605
7608
  // notify this client of error
7606
7609
  console.error('Login failed', err);
7607
- (_f = client.setLoading) === null || _f === void 0 ? void 0 : _f.call(client, false);
7608
- (_g = client.setLoggedIn) === null || _g === void 0 ? void 0 : _g.call(client, false, null);
7610
+ (_g = client.setLoading) === null || _g === void 0 ? void 0 : _g.call(client, false);
7611
+ (_h = client.setLoggedIn) === null || _h === void 0 ? void 0 : _h.call(client, false, null);
7609
7612
  return { status: 'error' };
7610
7613
  }
7611
7614
  }