@realtimexsco/live-chat 1.5.1 → 1.5.2

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 CHANGED
@@ -817,6 +817,12 @@ var init_call_store = __esm({
817
817
  clearRingTimer();
818
818
  set({ ...idleState });
819
819
  },
820
+ notifyServerCallFailed: () => {
821
+ const { callId } = get();
822
+ if (callId) {
823
+ exports.socketService.emitCallEnd({ callId });
824
+ }
825
+ },
820
826
  _receiveIncoming: (payload) => {
821
827
  const currentStatus = get().uiStatus;
822
828
  if (currentStatus !== "idle") {
@@ -6234,9 +6240,16 @@ var CallOverlay = () => {
6234
6240
  const callStartedAt = exports.useCallStore((s) => s.callStartedAt);
6235
6241
  const cancelCall = exports.useCallStore((s) => s.cancelCall);
6236
6242
  const reset = exports.useCallStore((s) => s.reset);
6243
+ const notifyServerCallFailed = exports.useCallStore((s) => s.notifyServerCallFailed);
6237
6244
  const [sessionError, setSessionError] = React9.useState(null);
6238
6245
  const secondsLeft = useRingCountdown(uiStatus === "ringing-out", callId);
6239
6246
  const duration = useCallDuration(callStartedAt);
6247
+ React9.useEffect(() => {
6248
+ setSessionError(null);
6249
+ }, [callId]);
6250
+ React9.useEffect(() => {
6251
+ if (sessionError) notifyServerCallFailed();
6252
+ }, [sessionError, notifyServerCallFailed]);
6240
6253
  const isOpen = uiStatus !== "idle" && uiStatus !== "incoming";
6241
6254
  if (!isOpen) return null;
6242
6255
  const displayError = error || sessionError;