@getwidgets/live-chat-widget 1.0.9 → 1.1.0

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.
@@ -19750,7 +19750,7 @@
19750
19750
  }
19751
19751
  return sessionId;
19752
19752
  };
19753
- const LiveChatWidget = ({ widgetId, apiKey, name: name2 = null, email = null, unique_id = null }) => {
19753
+ const LiveChatWidget = ({ widgetId, name: name2 = null, email = null, unique_id = null }) => {
19754
19754
  var _a, _b;
19755
19755
  const [config, setConfig] = reactExports.useState(null);
19756
19756
  const [messages, setMessages] = reactExports.useState([]);
@@ -19843,6 +19843,7 @@
19843
19843
  const stored = localStorage.getItem("widgetkraft_livechat_authtoken");
19844
19844
  setLocalStorageToken(stored);
19845
19845
  if (stored && !authToken) setAuthToken(stored);
19846
+ if (stored) setShowContactFields(false);
19846
19847
  } catch (e) {
19847
19848
  }
19848
19849
  const handleStorageChange = (e) => {
@@ -19851,6 +19852,7 @@
19851
19852
  const stored = localStorage.getItem("widgetkraft_livechat_authtoken");
19852
19853
  setLocalStorageToken(stored);
19853
19854
  if (stored && !authToken) setAuthToken(stored);
19855
+ if (stored) setShowContactFields(false);
19854
19856
  } catch (err) {
19855
19857
  }
19856
19858
  }
@@ -19908,7 +19910,7 @@
19908
19910
  reactExports.useEffect(() => {
19909
19911
  if (!widgetId) return;
19910
19912
  fetchWidgetConfig(widgetId).then((data) => setConfig(data)).catch((err) => console.error("Failed to load widget config:", err));
19911
- }, [widgetId, apiKey]);
19913
+ }, [widgetId]);
19912
19914
  reactExports.useEffect(() => {
19913
19915
  const checkAndInitializeSession = async () => {
19914
19916
  var _a2;
@@ -20795,7 +20797,7 @@
20795
20797
  }
20796
20798
  `));
20797
20799
  };
20798
- function init({ widgetId, apiKey, mode = "inline", name: name2 = null, email = null, unique_id = null }) {
20800
+ function init({ widgetId, mode = "inline", name: name2 = null, email = null, unique_id = null }) {
20799
20801
  const container = document.getElementById("livechat-root");
20800
20802
  if (!container) {
20801
20803
  console.error("Live Chat Widget root element (#livechat-root) not found.");
@@ -20819,7 +20821,6 @@
20819
20821
  LiveChatWidget,
20820
20822
  {
20821
20823
  widgetId,
20822
- apiKey,
20823
20824
  name: name2,
20824
20825
  email,
20825
20826
  unique_id
@@ -20839,26 +20840,29 @@
20839
20840
  mountPoint.appendChild(errDiv);
20840
20841
  }
20841
20842
  }
20843
+ let userDetails = { name: null, email: null, unique_id: null };
20842
20844
  function setUser({ name: name2, email, unique_id }) {
20843
- const container = document.getElementById("livechat-root");
20844
- if (container && container.__livechat_mounted) {
20845
- const shadowRoot = container.shadowRoot;
20846
- if (shadowRoot) {
20847
- const mountPoint = shadowRoot.getElementById("live-chat-widget-mount") || shadowRoot.querySelector("#live-chat-widget-mount");
20848
- if (mountPoint) {
20849
- const root2 = client.createRoot(mountPoint);
20850
- root2.render(
20851
- /* @__PURE__ */ React.createElement(React.StrictMode, null, /* @__PURE__ */ React.createElement(
20852
- LiveChatWidget,
20853
- {
20854
- widgetId: container.dataset.widgetId,
20855
- apiKey: container.dataset.apiKey,
20856
- name: name2,
20857
- email,
20858
- unique_id
20859
- }
20860
- ))
20861
- );
20845
+ if (userDetails.name !== name2 || userDetails.email !== email || userDetails.unique_id !== unique_id) {
20846
+ userDetails = { name: name2, email, unique_id };
20847
+ const container = document.getElementById("livechat-root");
20848
+ if (container && container.__livechat_mounted) {
20849
+ const shadowRoot = container.shadowRoot;
20850
+ if (shadowRoot) {
20851
+ const mountPoint = shadowRoot.getElementById("live-chat-widget-mount") || shadowRoot.querySelector("#live-chat-widget-mount");
20852
+ if (mountPoint) {
20853
+ const root2 = client.createRoot(mountPoint);
20854
+ root2.render(
20855
+ /* @__PURE__ */ React.createElement(React.StrictMode, null, /* @__PURE__ */ React.createElement(
20856
+ LiveChatWidget,
20857
+ {
20858
+ widgetId: container.dataset.widgetId,
20859
+ name: name2,
20860
+ email,
20861
+ unique_id
20862
+ }
20863
+ ))
20864
+ );
20865
+ }
20862
20866
  }
20863
20867
  }
20864
20868
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@getwidgets/live-chat-widget",
3
- "version": "1.0.9",
3
+ "version": "1.1.0",
4
4
  "main": "dist/live-chat-widget.umd.js",
5
5
  "unpkg": "dist/live-chat-widget.umd.js",
6
6
  "type": "module",