@vendorflow/components 2.0.39 → 2.0.40

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.
@@ -81,6 +81,7 @@ function useInfiniteScroll(_a) {
81
81
  var scrollParent = _a.scrollParent, scrollBody = _a.scrollBody, isLoading = _a.isLoading, isFetching = _a.isFetching, isReverse = _a.isReverse, hasNextPage = _a.hasNextPage, fetchNextPage = _a.fetchNextPage;
82
82
  var prevPosition = (0, react_2.useRef)();
83
83
  var observer = (0, react_2.useRef)();
84
+ var _d = __read((0, react_2.useState)(false), 2), isScrollInit = _d[0], setScrollInit = _d[1];
84
85
  var hasScrollbar = (0, react_2.useMemo)(function () {
85
86
  if (scrollParent.current && scrollBody.current) {
86
87
  return scrollBody.current.clientHeight > scrollParent.current.clientHeight;
@@ -102,6 +103,7 @@ function useInfiniteScroll(_a) {
102
103
  var scrollHeight = (scrollBody.current || { scrollHeight: 0 }).scrollHeight;
103
104
  var scrollToValue = isReverse ? scrollHeight : 0;
104
105
  (_a = scrollParent.current) === null || _a === void 0 ? void 0 : _a.scrollTo(0, scrollToValue);
106
+ setScrollInit(true);
105
107
  }
106
108
  // this callback is used and fired based on the state of the element it is attached to
107
109
  return (0, react_2.useCallback)(function (node) {
@@ -113,7 +115,7 @@ function useInfiniteScroll(_a) {
113
115
  }
114
116
  observer.current = new IntersectionObserver(function (entries) {
115
117
  if (entries[0].isIntersecting && hasNextPage && fetchNextPage) {
116
- if (scrollBody.current && isReverse && hasScrollbar) {
118
+ if (scrollBody.current && isReverse && isScrollInit) {
117
119
  // save the last element, so that we can scroll to it after the new data loads in
118
120
  prevPosition.current = scrollBody.current.clientHeight;
119
121
  console.log('saving prev position: ', prevPosition.current);
@@ -134,6 +136,6 @@ function useInfiniteScroll(_a) {
134
136
  }
135
137
  observer.current.observe(node);
136
138
  }
137
- }, [isLoading, isFetching, isReverse, hasNextPage, fetchNextPage, scrollParent, scrollBody, hasScrollbar]);
139
+ }, [isLoading, isFetching, isReverse, hasNextPage, fetchNextPage, scrollParent, scrollBody, isScrollInit]);
138
140
  }
139
141
  var templateObject_1, templateObject_2, templateObject_3, templateObject_4;
@@ -85,7 +85,7 @@ function ChatInterface() {
85
85
  setTimeout(function () {
86
86
  setMessages(__spreadArray(__spreadArray([], __read(messages), false), __read(generateMessagePage()), false));
87
87
  setFetching(false);
88
- }, 1000);
88
+ }, 100);
89
89
  }
90
90
  function handleSend(message) {
91
91
  setSubmitting(true);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vendorflow/components",
3
- "version": "2.0.39",
3
+ "version": "2.0.40",
4
4
  "description": "React components for vendorflow",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",