@opencx/widget-core 5.4.0 → 5.4.2

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
@@ -41,20 +41,19 @@ class ie {
41
41
  sessionsState: o,
42
42
  setSessions: r
43
43
  }) {
44
- this.state = new S({ unreadSessionIds: [], count: 0 }), this.viewingSessionId = null, this.readsInFlight = /* @__PURE__ */ new Set(), this.retryTimer = null, this.lastNotifiedCount = null, this.subscriptions = [], this.disposed = !1, this.dispose = () => {
44
+ this.state = new S({ unreadSessionIds: [], count: 0 }), this.viewingSessionId = null, this.readsInFlight = /* @__PURE__ */ new Set(), this.retryTimer = null, this.lastNotifiedCount = null, this.subscriptions = [], this.disposed = !1, this.reportedSessionIds = /* @__PURE__ */ new Set(), this.dispose = () => {
45
45
  this.disposed = !0, this.subscriptions.forEach((_) => _()), this.subscriptions = [], this.viewingSessionId = null, this.retryTimer && clearTimeout(this.retryTimer), this.retryTimer = null;
46
46
  }, this.setViewingSessionId = (_) => {
47
47
  this.viewingSessionId = _, this.evaluate(this.sessionsState.get().data);
48
48
  }, this.evaluate = (_) => {
49
49
  const s = [];
50
- for (const a of _)
51
- if (a.unread === !0) {
52
- if (a.id === this.viewingSessionId) {
53
- this.markViewedSessionRead(a.id);
54
- continue;
55
- }
56
- s.push(a.id);
50
+ for (const a of _) {
51
+ if (a.id === this.viewingSessionId) {
52
+ (a.unread === !0 || a.unread === !1 && !this.reportedSessionIds.has(a.id)) && this.markViewedSessionRead(a.id);
53
+ continue;
57
54
  }
55
+ a.unread === !0 && s.push(a.id);
56
+ }
58
57
  this.state.set({ unreadSessionIds: s, count: s.length }), this.notifyCount(s.length);
59
58
  }, this.markViewedSessionRead = (_) => {
60
59
  if (this.readsInFlight.has(_)) return;
@@ -62,6 +61,7 @@ class ie {
62
61
  let s = !1;
63
62
  this.api.markSessionRead({ sessionId: _ }).then(({ data: a }) => {
64
63
  if (!a || this.disposed) return;
64
+ this.reportedSessionIds.add(_);
65
65
  const n = this.sessionsState.get().data.find((c) => c.id === a.id);
66
66
  n && re(n, a) ? s = !0 : this.setSessions([a]);
67
67
  }).catch((a) => {
@@ -5273,7 +5273,7 @@ class Ia {
5273
5273
  );
5274
5274
  if (a.aborted || !d)
5275
5275
  return { session: null, status: p == null ? void 0 : p.status, error: l };
5276
- this.sessionState.setPartial({ session: d });
5276
+ this.sessionState.setPartial({ session: d }), this.setSessions([d]);
5277
5277
  try {
5278
5278
  (g = (m = this.config.hooks) == null ? void 0 : m.onSessionCreated) == null || g.call(m, { session: d });
5279
5279
  } catch (b) {
@@ -5483,7 +5483,7 @@ const Ma = (i, e, { sendsPageContext: t }) => {
5483
5483
  m.length !== u.length && this.state.setPartial({ messages: m });
5484
5484
  }, this.notifySendAccepted = (l) => {
5485
5485
  var p;
5486
- l.optionReply && this.setMessageOptionPick(
5486
+ this.state.setPartial({ lastAIResMightSolveUserIssue: !1 }), l.optionReply && this.setMessageOptionPick(
5487
5487
  l.optionReply.messageId,
5488
5488
  l.optionReply.optionId
5489
5489
  );