@veltdev/react 3.0.60 → 3.0.62

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.
@@ -1,6 +1,7 @@
1
1
  import React from 'react';
2
2
  export interface IVeltCommentPlayerTimelineProps {
3
3
  totalMediaLength?: number;
4
+ offset?: number;
4
5
  shadowDom?: boolean;
5
6
  videoPlayerId?: string;
6
7
  onCommentClick?: Function;
@@ -1,3 +1,3 @@
1
- export declare const VELT_SDK_VERSION = "3.0.60";
1
+ export declare const VELT_SDK_VERSION = "3.0.62";
2
2
  export declare const VELT_SDK_INIT_EVENT = "onVeltInit";
3
3
  export declare const VELT_TAB_ID = "veltTabId";
@@ -4,7 +4,7 @@ declare class LiveStateDataConfig {
4
4
  }
5
5
  export declare function useLiveStateSyncUtils(): LiveStateSyncElement | undefined;
6
6
  export declare function useLiveStateData(liveStateDataId?: string, liveStateDataConfig?: LiveStateDataConfig): any;
7
- export declare function useSetLiveStateData(liveStateDataId: string, liveStateData: any): any;
7
+ export declare function useSetLiveStateData(liveStateDataId: string, liveStateData: any): void;
8
8
  export declare function useUserEditorState(): UserEditorAccess | null;
9
9
  export declare function useEditor(): User | null;
10
10
  export declare function useEditorAccessTimer(): EditorAccessTimer;
package/esm/index.js CHANGED
@@ -132,7 +132,7 @@ var loadVelt = function (callback, version, staging, develop, proxyDomain) {
132
132
  }
133
133
  };
134
134
 
135
- var VELT_SDK_VERSION = '3.0.60';
135
+ var VELT_SDK_VERSION = '3.0.62';
136
136
  var VELT_SDK_INIT_EVENT = 'onVeltInit';
137
137
  var VELT_TAB_ID = 'veltTabId';
138
138
 
@@ -746,7 +746,7 @@ var SnippylyUserRequestTool = function (props) {
746
746
  };
747
747
 
748
748
  var VeltCommentPlayerTimeline = function (props) {
749
- var totalMediaLength = props.totalMediaLength, onCommentClick = props.onCommentClick, shadowDom = props.shadowDom, videoPlayerId = props.videoPlayerId, onReactionClick = props.onReactionClick;
749
+ var totalMediaLength = props.totalMediaLength, offset = props.offset, onCommentClick = props.onCommentClick, shadowDom = props.shadowDom, videoPlayerId = props.videoPlayerId, onReactionClick = props.onReactionClick;
750
750
  var ref = useRef();
751
751
  var onCommentClickRef = useRef(onCommentClick);
752
752
  var onReactionClickRef = useRef(onReactionClick);
@@ -783,7 +783,7 @@ var VeltCommentPlayerTimeline = function (props) {
783
783
  }
784
784
  };
785
785
  }, []);
786
- return (React.createElement("velt-comment-player-timeline", { ref: ref, "shadow-dom": [true, false].includes(shadowDom) ? (shadowDom ? 'true' : 'false') : undefined, "total-media-length": totalMediaLength, "video-player-id": videoPlayerId }));
786
+ return (React.createElement("velt-comment-player-timeline", { ref: ref, "shadow-dom": [true, false].includes(shadowDom) ? (shadowDom ? 'true' : 'false') : undefined, "total-media-length": totalMediaLength, offset: offset, "video-player-id": videoPlayerId }));
787
787
  };
788
788
 
789
789
  var VeltVideoPlayer = function (props) {
@@ -4760,25 +4760,43 @@ function useLiveStateSyncUtils() {
4760
4760
  function useLiveStateData(liveStateDataId, liveStateDataConfig) {
4761
4761
  var liveStateSyncElement = useLiveStateSyncUtils();
4762
4762
  var _a = React.useState(), data = _a[0], setData = _a[1];
4763
+ var subscriptionRef = React.useRef();
4764
+ // Memoize inputs
4765
+ var inputs = React.useMemo(function () {
4766
+ return { liveStateDataId: liveStateDataId, liveStateDataConfig: liveStateDataConfig };
4767
+ }, [liveStateDataId, JSON.stringify(liveStateDataConfig)]);
4763
4768
  useEffect(function () {
4764
4769
  if (!(liveStateSyncElement === null || liveStateSyncElement === void 0 ? void 0 : liveStateSyncElement.getLiveStateData))
4765
4770
  return;
4766
- var subscription = liveStateSyncElement.getLiveStateData(liveStateDataId, liveStateDataConfig).subscribe(function (res) {
4771
+ if (subscriptionRef.current) {
4772
+ subscriptionRef.current.unsubscribe();
4773
+ }
4774
+ var subscription = liveStateSyncElement.getLiveStateData(inputs.liveStateDataId, inputs.liveStateDataConfig)
4775
+ .subscribe(function (res) {
4767
4776
  setData(res);
4768
4777
  });
4778
+ subscriptionRef.current = subscription;
4769
4779
  return function () {
4770
- subscription.unsubscribe();
4780
+ if (subscriptionRef.current) {
4781
+ subscriptionRef.current.unsubscribe();
4782
+ }
4771
4783
  };
4772
- }, [liveStateSyncElement === null || liveStateSyncElement === void 0 ? void 0 : liveStateSyncElement.getLiveStateData]);
4784
+ }, [liveStateSyncElement === null || liveStateSyncElement === void 0 ? void 0 : liveStateSyncElement.getLiveStateData, inputs]);
4773
4785
  return data;
4774
4786
  }
4775
4787
  function useSetLiveStateData(liveStateDataId, liveStateData) {
4776
4788
  var liveStateSyncElement = useLiveStateSyncUtils();
4789
+ // Memoize inputs
4790
+ var inputs = React.useMemo(function () {
4791
+ return { liveStateDataId: liveStateDataId, liveStateData: liveStateData };
4792
+ }, [liveStateDataId, JSON.stringify(liveStateData)]);
4777
4793
  React.useEffect(function () {
4778
- if (liveStateSyncElement && liveStateDataId && liveStateData) {
4779
- liveStateSyncElement === null || liveStateSyncElement === void 0 ? void 0 : liveStateSyncElement.setLiveStateData(liveStateDataId, liveStateData);
4794
+ if (!(liveStateSyncElement === null || liveStateSyncElement === void 0 ? void 0 : liveStateSyncElement.setLiveStateData))
4795
+ return;
4796
+ if (inputs.liveStateDataId && inputs.liveStateData) {
4797
+ liveStateSyncElement.setLiveStateData(inputs.liveStateDataId, inputs.liveStateData);
4780
4798
  }
4781
- }, [liveStateSyncElement === null || liveStateSyncElement === void 0 ? void 0 : liveStateSyncElement.setLiveStateData]);
4799
+ }, [liveStateSyncElement === null || liveStateSyncElement === void 0 ? void 0 : liveStateSyncElement.setLiveStateData, inputs]);
4782
4800
  }
4783
4801
  function useUserEditorState() {
4784
4802
  var liveStateSyncElement = useLiveStateSyncUtils();
@@ -5074,31 +5092,53 @@ function useViewsUtils() {
5074
5092
  function useUniqueViewsByUser(clientLocationId) {
5075
5093
  var viewsElement = useViewsUtils();
5076
5094
  var _a = React.useState(null), data = _a[0], setData = _a[1];
5095
+ var subscriptionRef = React.useRef();
5096
+ // Memoize the input
5097
+ var memoizedClientLocationId = React.useMemo(function () { return clientLocationId; }, [clientLocationId]);
5077
5098
  useEffect(function () {
5078
5099
  if (!(viewsElement === null || viewsElement === void 0 ? void 0 : viewsElement.getUniqueViewsByUser))
5079
5100
  return;
5080
- var subscription = viewsElement.getUniqueViewsByUser(clientLocationId).subscribe(function (res) {
5101
+ // Unsubscribe from the previous subscription if it exists
5102
+ if (subscriptionRef.current) {
5103
+ subscriptionRef.current.unsubscribe();
5104
+ }
5105
+ var subscription = viewsElement.getUniqueViewsByUser(memoizedClientLocationId).subscribe(function (res) {
5081
5106
  setData(res);
5082
5107
  });
5108
+ // Store the new subscription
5109
+ subscriptionRef.current = subscription;
5083
5110
  return function () {
5084
- subscription.unsubscribe();
5111
+ if (subscriptionRef.current) {
5112
+ subscriptionRef.current.unsubscribe();
5113
+ }
5085
5114
  };
5086
- }, [viewsElement === null || viewsElement === void 0 ? void 0 : viewsElement.getUniqueViewsByUser]);
5115
+ }, [viewsElement === null || viewsElement === void 0 ? void 0 : viewsElement.getUniqueViewsByUser, memoizedClientLocationId]);
5087
5116
  return data;
5088
5117
  }
5089
5118
  function useUniqueViewsByDate(clientLocationId) {
5090
5119
  var viewsElement = useViewsUtils();
5091
5120
  var _a = React.useState(null), data = _a[0], setData = _a[1];
5121
+ var subscriptionRef = React.useRef();
5122
+ // Memoize the input
5123
+ var memoizedClientLocationId = React.useMemo(function () { return clientLocationId; }, [clientLocationId]);
5092
5124
  useEffect(function () {
5093
5125
  if (!(viewsElement === null || viewsElement === void 0 ? void 0 : viewsElement.getUniqueViewsByDate))
5094
5126
  return;
5095
- var subscription = viewsElement.getUniqueViewsByDate(clientLocationId).subscribe(function (res) {
5127
+ // Unsubscribe from the previous subscription if it exists
5128
+ if (subscriptionRef.current) {
5129
+ subscriptionRef.current.unsubscribe();
5130
+ }
5131
+ var subscription = viewsElement.getUniqueViewsByDate(memoizedClientLocationId).subscribe(function (res) {
5096
5132
  setData(res);
5097
5133
  });
5134
+ // Store the new subscription
5135
+ subscriptionRef.current = subscription;
5098
5136
  return function () {
5099
- subscription.unsubscribe();
5137
+ if (subscriptionRef.current) {
5138
+ subscriptionRef.current.unsubscribe();
5139
+ }
5100
5140
  };
5101
- }, [viewsElement === null || viewsElement === void 0 ? void 0 : viewsElement.getUniqueViewsByDate]);
5141
+ }, [viewsElement === null || viewsElement === void 0 ? void 0 : viewsElement.getUniqueViewsByDate, memoizedClientLocationId]);
5102
5142
  return data;
5103
5143
  }
5104
5144