From 698a88e6f06ee19fc52331540bd7c2fa4e8cb249 Mon Sep 17 00:00:00 2001
From: Kevin Martinez <kevin.martinez@mindshore.io>
Date: Mon, 26 Feb 2024 09:52:56 -0300
Subject: [PATCH] Fix infinite scroll in VnPaginate

---
 src/components/ui/VnPaginate.vue | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/src/components/ui/VnPaginate.vue b/src/components/ui/VnPaginate.vue
index 4c38c1c1a..24944e322 100644
--- a/src/components/ui/VnPaginate.vue
+++ b/src/components/ui/VnPaginate.vue
@@ -44,7 +44,7 @@ const props = defineProps({
     },
     offset: {
         type: Number,
-        default: 500,
+        default: 0,
     },
     skeleton: {
         type: Boolean,
@@ -54,6 +54,10 @@ const props = defineProps({
         type: Function,
         default: null,
     },
+    disableInfiniteScroll: {
+        type: Boolean,
+        default: false,
+    },
 });
 
 const emit = defineEmits(['onFetch', 'onPaginate']);
@@ -122,10 +126,11 @@ async function paginate() {
     emit('onPaginate');
 }
 
-async function onLoad(...params) {
-    if (!store.data) return;
+async function onLoad(index, done) {
+    if (!store.data) {
+        return done();
+    }
 
-    const done = params[1];
     if (store.data.length === 0 || !props.url) return done(false);
 
     pagination.value.page = pagination.value.page + 1;
@@ -174,7 +179,8 @@ async function onLoad(...params) {
         v-if="store.data"
         @load="onLoad"
         :offset="offset"
-        class="full-width full-height"
+        :disable="disableInfiniteScroll || !arrayData.hasMoreData.value"
+        class="full-width"
     >
         <slot name="body" :rows="store.data"></slot>
         <div v-if="isLoading" class="info-row q-pa-md text-center">