keystone-design-bootstrap 1.0.91 → 1.0.93

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
@@ -20046,24 +20046,21 @@ function ChatWidget({
20046
20046
  const [messages, setMessages] = useState33([]);
20047
20047
  const [inputValue, setInputValue] = useState33("");
20048
20048
  const [isLoading, setIsLoading] = useState33(false);
20049
- const [sessionId, setSessionId] = useState33("");
20049
+ const [sessionId] = useState33(() => {
20050
+ var _a;
20051
+ if (contactId) return "";
20052
+ if (providedSessionId) return providedSessionId;
20053
+ if (typeof window === "undefined") return "";
20054
+ return (_a = localStorage.getItem("keystone_chat_session_id")) != null ? _a : `session_${Date.now()}_${Math.random().toString(36).slice(2, 11)}`;
20055
+ });
20050
20056
  const [waitingForReply, setWaitingForReply] = useState33(false);
20051
20057
  const messagesEndRef = useRef20(null);
20052
20058
  useEffect14(() => {
20053
- if (contactId) return;
20054
- if (providedSessionId) {
20055
- setSessionId(providedSessionId);
20056
- } else {
20057
- const stored = localStorage.getItem("keystone_chat_session_id");
20058
- if (stored) {
20059
- setSessionId(stored);
20060
- } else {
20061
- const newId = `session_${Date.now()}_${Math.random().toString(36).slice(2, 11)}`;
20062
- localStorage.setItem("keystone_chat_session_id", newId);
20063
- setSessionId(newId);
20064
- }
20059
+ if (contactId || providedSessionId || !sessionId) return;
20060
+ if (localStorage.getItem("keystone_chat_session_id") !== sessionId) {
20061
+ localStorage.setItem("keystone_chat_session_id", sessionId);
20065
20062
  }
20066
- }, [contactId, providedSessionId]);
20063
+ }, [contactId, providedSessionId, sessionId]);
20067
20064
  const loadMessages = useCallback12(async () => {
20068
20065
  if (!contactId && !sessionId) return [];
20069
20066
  try {