@wexio/messenger-widget-react 1.1.2 → 1.1.3

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.
@@ -1099,13 +1099,13 @@ function Cr(e) {
1099
1099
  }
1100
1100
  //#endregion
1101
1101
  //#region lib/use-visitor-unread.ts
1102
- function wr({ chatId: e, isDummy: t }) {
1103
- let n = V("demo"), [r, i] = X(!1), [a, o] = X(0), [s, c] = X(null), l = Y(/* @__PURE__ */ new Set()), u = Y(null), d = Y(!1), [f] = cn({ fetchPolicy: "network-only" });
1102
+ function wr({ chatId: e, isDummy: t, isLoading: n }) {
1103
+ let r = V("demo"), [i, a] = X(!1), [o, s] = X(0), [c, l] = X(null), u = Y(/* @__PURE__ */ new Set()), d = Y(null), f = Y(!1), [p] = cn({ fetchPolicy: "network-only" });
1104
1104
  J(() => {
1105
- t || !e || u.current !== e && (u.current = e, l.current = /* @__PURE__ */ new Set(), d.current = !1, f({ variables: { chatId: e } }).then((e) => {
1106
- if (d.current) return;
1105
+ t || !e || d.current !== e && (d.current = e, u.current = /* @__PURE__ */ new Set(), f.current = !1, p({ variables: { chatId: e } }).then((e) => {
1106
+ if (f.current) return;
1107
1107
  let t = e.data?.visitorChatUnread;
1108
- if (t) if (o(t.count ?? 0), t.lastMessage) {
1108
+ if (t) if (s(t.count ?? 0), t.lastMessage) {
1109
1109
  let e = {
1110
1110
  id: t.lastMessage.id,
1111
1111
  text: t.lastMessage.text ?? null,
@@ -1116,32 +1116,32 @@ function wr({ chatId: e, isDummy: t }) {
1116
1116
  },
1117
1117
  buttons: Er(t.lastMessage.buttons)
1118
1118
  };
1119
- l.current.add(e.id), c(e);
1120
- } else c(null);
1119
+ u.current.add(e.id), l(e);
1120
+ } else l(null);
1121
1121
  }).catch(() => {}));
1122
1122
  }, [
1123
1123
  e,
1124
1124
  t,
1125
- f
1125
+ p
1126
1126
  ]);
1127
- let p = q(() => {
1127
+ let m = q(() => {
1128
1128
  if (t) {
1129
- i(!0);
1129
+ a(!0);
1130
1130
  return;
1131
1131
  }
1132
- o(0), c(null), d.current = !0;
1133
- }, [t]), m = q((e) => {
1132
+ s(0), l(null), f.current = !0;
1133
+ }, [t]), h = q((e) => {
1134
1134
  if (t || e.kind === "typing" || e.kind === "read-receipt" || e.kind === "assignment") return;
1135
1135
  let n = e.from ?? e.sender;
1136
1136
  if (n?.kind === "visitor") return;
1137
1137
  let r = e.externalMessageId;
1138
- if (!r || l.current.has(r)) return;
1139
- l.current.add(r), o((e) => e + 1);
1138
+ if (!r || u.current.has(r)) return;
1139
+ u.current.add(r), s((e) => e + 1);
1140
1140
  let i = Array.isArray(e.buttons) ? e.buttons.map((e) => ({
1141
1141
  text: e.label,
1142
1142
  payload: e.value
1143
1143
  })) : [];
1144
- c({
1144
+ l({
1145
1145
  id: r,
1146
1146
  text: e.text ?? null,
1147
1147
  sender: {
@@ -1151,28 +1151,28 @@ function wr({ chatId: e, isDummy: t }) {
1151
1151
  },
1152
1152
  buttons: i
1153
1153
  });
1154
- }, [t]), h = q((e) => {
1154
+ }, [t]), g = q((e) => {
1155
1155
  if (t || e.length === 0) return;
1156
1156
  let n = 0;
1157
- for (let t of e) l.current.has(t) && (l.current.delete(t), n += 1);
1158
- n > 0 && o((e) => Math.max(0, e - n)), c((t) => t && (e.includes(t.id) ? null : t));
1157
+ for (let t of e) u.current.has(t) && (u.current.delete(t), n += 1);
1158
+ n > 0 && s((e) => Math.max(0, e - n)), l((t) => t && (e.includes(t.id) ? null : t));
1159
1159
  }, [t]);
1160
- if (t) {
1161
- let e = r ? null : Tr(n);
1160
+ if (t && !n) {
1161
+ let e = i ? null : Tr(r);
1162
1162
  return {
1163
1163
  count: +!!e,
1164
1164
  lastMessage: e,
1165
- clear: p,
1166
- noteInbound: m,
1167
- noteRead: h
1165
+ clear: m,
1166
+ noteInbound: h,
1167
+ noteRead: g
1168
1168
  };
1169
1169
  }
1170
1170
  return {
1171
- count: a,
1172
- lastMessage: s,
1173
- clear: p,
1174
- noteInbound: m,
1175
- noteRead: h
1171
+ count: o,
1172
+ lastMessage: c,
1173
+ clear: m,
1174
+ noteInbound: h,
1175
+ noteRead: g
1176
1176
  };
1177
1177
  }
1178
1178
  function Tr(e) {
@@ -20293,7 +20293,8 @@ function $v() {
20293
20293
  ]);
20294
20294
  let _e = wr({
20295
20295
  chatId: M.chatId,
20296
- isDummy: o
20296
+ isDummy: o,
20297
+ isLoading: s
20297
20298
  }), ve = Pn({
20298
20299
  enabled: i === "production" && !o && !!a.features.news,
20299
20300
  locale: t
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wexio/messenger-widget-react",
3
- "version": "1.1.2",
3
+ "version": "1.1.3",
4
4
  "description": "Native React component embed for the Wexio web messenger. Renders inside a Shadow DOM portal for style isolation.",
5
5
  "license": "MIT",
6
6
  "private": false,