@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.
- package/dist/widget-react.js +30 -29
- package/package.json +1 -1
package/dist/widget-react.js
CHANGED
|
@@ -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
|
|
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 ||
|
|
1106
|
-
if (
|
|
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 (
|
|
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
|
-
|
|
1120
|
-
} else
|
|
1119
|
+
u.current.add(e.id), l(e);
|
|
1120
|
+
} else l(null);
|
|
1121
1121
|
}).catch(() => {}));
|
|
1122
1122
|
}, [
|
|
1123
1123
|
e,
|
|
1124
1124
|
t,
|
|
1125
|
-
|
|
1125
|
+
p
|
|
1126
1126
|
]);
|
|
1127
|
-
let
|
|
1127
|
+
let m = q(() => {
|
|
1128
1128
|
if (t) {
|
|
1129
|
-
|
|
1129
|
+
a(!0);
|
|
1130
1130
|
return;
|
|
1131
1131
|
}
|
|
1132
|
-
|
|
1133
|
-
}, [t]),
|
|
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 ||
|
|
1139
|
-
|
|
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
|
-
|
|
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]),
|
|
1154
|
+
}, [t]), g = q((e) => {
|
|
1155
1155
|
if (t || e.length === 0) return;
|
|
1156
1156
|
let n = 0;
|
|
1157
|
-
for (let t of e)
|
|
1158
|
-
n > 0 &&
|
|
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 =
|
|
1160
|
+
if (t && !n) {
|
|
1161
|
+
let e = i ? null : Tr(r);
|
|
1162
1162
|
return {
|
|
1163
1163
|
count: +!!e,
|
|
1164
1164
|
lastMessage: e,
|
|
1165
|
-
clear:
|
|
1166
|
-
noteInbound:
|
|
1167
|
-
noteRead:
|
|
1165
|
+
clear: m,
|
|
1166
|
+
noteInbound: h,
|
|
1167
|
+
noteRead: g
|
|
1168
1168
|
};
|
|
1169
1169
|
}
|
|
1170
1170
|
return {
|
|
1171
|
-
count:
|
|
1172
|
-
lastMessage:
|
|
1173
|
-
clear:
|
|
1174
|
-
noteInbound:
|
|
1175
|
-
noteRead:
|
|
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