@baseportal/chat-widget 0.1.2 → 0.1.4
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.cjs.js +25 -40
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +25 -40
- package/dist/index.esm.js.map +1 -1
- package/dist/index.iife.js +5 -5
- package/dist/index.iife.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs.js
CHANGED
|
@@ -202,6 +202,7 @@ var pt = {
|
|
|
202
202
|
placeholder: "Digite uma mensagem...",
|
|
203
203
|
closed: "Esta conversa foi encerrada.",
|
|
204
204
|
reopen: "Reabrir conversa",
|
|
205
|
+
newConversation: "Nova conversa",
|
|
205
206
|
attachFile: "Anexar arquivo",
|
|
206
207
|
uploading: "Enviando...",
|
|
207
208
|
fileTooLarge: "Arquivo muito grande (m\xE1x. 25MB)",
|
|
@@ -233,6 +234,7 @@ var en = {
|
|
|
233
234
|
placeholder: "Type a message...",
|
|
234
235
|
closed: "This conversation has been closed.",
|
|
235
236
|
reopen: "Reopen conversation",
|
|
237
|
+
newConversation: "New conversation",
|
|
236
238
|
attachFile: "Attach file",
|
|
237
239
|
uploading: "Uploading...",
|
|
238
240
|
fileTooLarge: "File too large (max 25MB)",
|
|
@@ -264,6 +266,7 @@ var es = {
|
|
|
264
266
|
placeholder: "Escribe un mensaje...",
|
|
265
267
|
closed: "Esta conversaci\xF3n ha sido cerrada.",
|
|
266
268
|
reopen: "Reabrir conversaci\xF3n",
|
|
269
|
+
newConversation: "Nueva conversaci\xF3n",
|
|
267
270
|
attachFile: "Adjuntar archivo",
|
|
268
271
|
uploading: "Subiendo...",
|
|
269
272
|
fileTooLarge: "Archivo demasiado grande (m\xE1x. 25MB)",
|
|
@@ -779,18 +782,11 @@ function ChatWindow({
|
|
|
779
782
|
if (storedId) {
|
|
780
783
|
try {
|
|
781
784
|
const conv = await apiClient.getConversation(storedId);
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
await startNewConversation();
|
|
788
|
-
}
|
|
789
|
-
} else {
|
|
790
|
-
const msgs = await apiClient.getMessages(storedId, { limit: 50 });
|
|
791
|
-
setMessages(Array.isArray(msgs) ? msgs.reverse() : []);
|
|
792
|
-
setConversation(conv);
|
|
793
|
-
setView("chat");
|
|
785
|
+
const msgs = await apiClient.getMessages(storedId, { limit: 50 });
|
|
786
|
+
setMessages(Array.isArray(msgs) ? msgs.reverse() : []);
|
|
787
|
+
setConversation(conv);
|
|
788
|
+
setView("chat");
|
|
789
|
+
if (conv.open) {
|
|
794
790
|
connectRealtime(storedId);
|
|
795
791
|
}
|
|
796
792
|
} catch {
|
|
@@ -847,21 +843,6 @@ function ChatWindow({
|
|
|
847
843
|
);
|
|
848
844
|
if (!conv.open) {
|
|
849
845
|
events.emit("conversation:closed", conv);
|
|
850
|
-
setTimeout(() => {
|
|
851
|
-
realtimeClient.unsubscribe();
|
|
852
|
-
storage.clear();
|
|
853
|
-
setConversation(null);
|
|
854
|
-
setMessages([]);
|
|
855
|
-
if (allowViewHistory) {
|
|
856
|
-
apiClient.getVisitorConversations().then(setConversations).catch(() => {
|
|
857
|
-
});
|
|
858
|
-
setView("conversations");
|
|
859
|
-
} else if (needsPreChat()) {
|
|
860
|
-
setView("prechat");
|
|
861
|
-
} else {
|
|
862
|
-
startNewConversationRef.current();
|
|
863
|
-
}
|
|
864
|
-
}, 2e3);
|
|
865
846
|
}
|
|
866
847
|
}
|
|
867
848
|
});
|
|
@@ -978,18 +959,7 @@ function ChatWindow({
|
|
|
978
959
|
const errMsg = e instanceof Error ? e.message : "";
|
|
979
960
|
if (errMsg.includes("Row not found") || errMsg.includes("404")) {
|
|
980
961
|
realtimeClient.unsubscribe();
|
|
981
|
-
|
|
982
|
-
setConversation(null);
|
|
983
|
-
setMessages([]);
|
|
984
|
-
if (allowViewHistory) {
|
|
985
|
-
apiClient.getVisitorConversations().then(setConversations).catch(() => {
|
|
986
|
-
});
|
|
987
|
-
setView("conversations");
|
|
988
|
-
} else if (needsPreChat()) {
|
|
989
|
-
setView("prechat");
|
|
990
|
-
} else {
|
|
991
|
-
await startNewConversationRef.current();
|
|
992
|
-
}
|
|
962
|
+
setConversation((prev) => prev ? { ...prev, open: false } : prev);
|
|
993
963
|
} else {
|
|
994
964
|
setInputValue(content);
|
|
995
965
|
}
|
|
@@ -997,6 +967,21 @@ function ChatWindow({
|
|
|
997
967
|
setSending(false);
|
|
998
968
|
}
|
|
999
969
|
}, [inputValue, uploadedFileId, conversation, sending, apiClient, events, realtimeClient, storage, allowViewHistory, needsPreChat]);
|
|
970
|
+
const handleNewConversation = (0, import_hooks5.useCallback)(async () => {
|
|
971
|
+
realtimeClient.unsubscribe();
|
|
972
|
+
storage.clear();
|
|
973
|
+
setConversation(null);
|
|
974
|
+
setMessages([]);
|
|
975
|
+
if (allowViewHistory) {
|
|
976
|
+
apiClient.getVisitorConversations().then(setConversations).catch(() => {
|
|
977
|
+
});
|
|
978
|
+
setView("conversations");
|
|
979
|
+
} else if (needsPreChat()) {
|
|
980
|
+
setView("prechat");
|
|
981
|
+
} else {
|
|
982
|
+
await startNewConversationRef.current();
|
|
983
|
+
}
|
|
984
|
+
}, [realtimeClient, storage, allowViewHistory, apiClient, needsPreChat]);
|
|
1000
985
|
const handleReopen = (0, import_hooks5.useCallback)(async () => {
|
|
1001
986
|
if (!conversation) return;
|
|
1002
987
|
try {
|
|
@@ -1068,7 +1053,7 @@ function ChatWindow({
|
|
|
1068
1053
|
}
|
|
1069
1054
|
) : /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { class: "bp-closed-banner", children: [
|
|
1070
1055
|
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { class: "bp-closed-banner__text", children: t.chat.closed }),
|
|
1071
|
-
channelInfo.config.allowReopenConversation
|
|
1056
|
+
channelInfo.config.allowReopenConversation ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("button", { class: "bp-closed-banner__reopen", onClick: handleReopen, children: t.chat.reopen }) : /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("button", { class: "bp-closed-banner__reopen", onClick: handleNewConversation, children: t.chat.newConversation })
|
|
1072
1057
|
] }),
|
|
1073
1058
|
channelInfo.config.privacyPolicyUrl && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { class: "bp-privacy-footer", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1074
1059
|
"a",
|