@trycourier/courier-ui-inbox 1.2.0 → 1.2.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.mjs CHANGED
@@ -157,6 +157,7 @@ const _CourierInboxDatastore = class _CourierInboxDatastore {
157
157
  __publicField(this, "_archiveDataSet");
158
158
  __publicField(this, "_dataStoreListeners", []);
159
159
  __publicField(this, "_unreadCount");
160
+ __publicField(this, "_removeMessageEventListener");
160
161
  __publicField(this, "isPaginatingInbox", false);
161
162
  __publicField(this, "isPaginatingArchive", false);
162
163
  }
@@ -262,7 +263,10 @@ const _CourierInboxDatastore = class _CourierInboxDatastore {
262
263
  (_c = (_b = Courier.shared.client) == null ? void 0 : _b.options.logger) == null ? void 0 : _c.info("CourierInbox socket not available");
263
264
  return;
264
265
  }
265
- socket.addMessageEventListener((event) => {
266
+ if (this._removeMessageEventListener) {
267
+ this._removeMessageEventListener();
268
+ }
269
+ this._removeMessageEventListener = socket.addMessageEventListener((event) => {
266
270
  if (event.event === InboxMessageEvent.NewMessage) {
267
271
  const message2 = event.data;
268
272
  this.addMessage(message2, 0, "inbox");
@@ -3287,8 +3291,10 @@ class CourierInbox extends CourierBaseElement {
3287
3291
  this._themeManager.subscribe((_) => {
3288
3292
  this.refreshTheme();
3289
3293
  });
3290
- this._authListener = Courier.shared.addAuthenticationListener((_) => {
3291
- this.refresh();
3294
+ this._authListener = Courier.shared.addAuthenticationListener(async ({ userId }) => {
3295
+ if (userId) {
3296
+ await this.refresh();
3297
+ }
3292
3298
  });
3293
3299
  if (!((_a = Courier.shared.client) == null ? void 0 : _a.options.userId)) {
3294
3300
  (_b = Courier.shared.client) == null ? void 0 : _b.options.logger.error("No user signed in. Please call Courier.shared.signIn(...) to load the inbox.");
@@ -4055,7 +4061,7 @@ class CourierInboxDatastoreEvents {
4055
4061
  }
4056
4062
  }
4057
4063
  Courier.shared.courierUserAgentName = "courier-ui-inbox";
4058
- Courier.shared.courierUserAgentVersion = "1.2.0";
4064
+ Courier.shared.courierUserAgentVersion = "1.2.1";
4059
4065
  export {
4060
4066
  Courier2 as Courier,
4061
4067
  CourierInbox,