|
84 | 84 | </div>
|
85 | 85 | <div>
|
86 | 86 | <el-timeline>
|
87 |
| - <template v-if="activities.length && !loading"> |
| 87 | + <template v-if="activities.length"> |
88 | 88 | <el-timeline-item
|
89 | 89 | v-for="activity in activities"
|
90 | 90 | :key="activity.id"
|
|
217 | 217 | class="app-page-spinner"
|
218 | 218 | />
|
219 | 219 | <div v-if="!noMore" class="flex justify-center pt-4">
|
220 |
| - <el-button |
221 |
| - class="btn btn-link btn-link--primary" |
| 220 | + <lf-button |
| 221 | + type="primary-ghost" |
222 | 222 | :disabled="loading"
|
223 | 223 | @click="fetchActivities()"
|
224 | 224 | >
|
225 |
| - <i class="ri-arrow-down-line mr-2" />Load |
226 |
| - more |
227 |
| - </el-button> |
| 225 | + Load more |
| 226 | + </lf-button> |
228 | 227 | </div>
|
229 | 228 | </div>
|
230 | 229 | </div>
|
@@ -262,6 +261,7 @@ import { getSegmentsFromProjectGroup } from '@/utils/segments';
|
262 | 261 | import { Platform } from '@/shared/modules/platform/types/Platform';
|
263 | 262 | import LfActivityDisplay from '@/shared/modules/activity/components/activity-display.vue';
|
264 | 263 | import moment from 'moment';
|
| 264 | +import LfButton from '@/ui-kit/button/Button.vue'; |
265 | 265 | import { ActivityService } from '../activity-service';
|
266 | 266 |
|
267 | 267 | const SearchIcon = h(
|
@@ -305,12 +305,12 @@ const enabledPlatforms = computed(() => CrowdIntegrations.enabledConfigs.concat(
|
305 | 305 | label: i.name,
|
306 | 306 | })));
|
307 | 307 |
|
308 |
| -const loading = ref(true); |
| 308 | +const loading = ref(false); |
309 | 309 | const platform = ref(null);
|
310 | 310 | const query = ref('');
|
311 | 311 | const activities = ref([]);
|
312 |
| -const limit = ref(50); |
313 |
| -const timestamp = ref(moment().toISOString()); |
| 312 | +const limit = ref(10); |
| 313 | +const timestamp = ref(moment(props.entity.lastActive).toISOString()); |
314 | 314 | const noMore = ref(false);
|
315 | 315 | const selectedSegment = ref(props.selectedSegment || null);
|
316 | 316 |
|
@@ -343,6 +343,9 @@ const segments = computed(() => {
|
343 | 343 | });
|
344 | 344 |
|
345 | 345 | const fetchActivities = async ({ reset } = { reset: false }) => {
|
| 346 | + if (loading.value) { |
| 347 | + return; |
| 348 | + } |
346 | 349 | const filterToApply = {
|
347 | 350 | platform: platform.value ? { in: [platform.value] } : undefined,
|
348 | 351 | };
|
@@ -373,12 +376,12 @@ const fetchActivities = async ({ reset } = { reset: false }) => {
|
373 | 376 | filterToApply.and = [
|
374 | 377 | {
|
375 | 378 | timestamp: {
|
376 |
| - lte: props.entity?.lastActive ?? timestamp.value, |
| 379 | + lte: timestamp.value, |
377 | 380 | },
|
378 | 381 | },
|
379 |
| - ...(props.entity?.lastActive ? [{ |
| 382 | + ...(timestamp.value ? [{ |
380 | 383 | timestamp: {
|
381 |
| - gte: moment(props.entity?.lastActive).subtract(1, 'month').toISOString(), |
| 384 | + gte: moment(timestamp.value).subtract(1, 'month').toISOString(), |
382 | 385 | },
|
383 | 386 | }] : []),
|
384 | 387 | ];
|
@@ -406,12 +409,16 @@ const fetchActivities = async ({ reset } = { reset: false }) => {
|
406 | 409 |
|
407 | 410 | const activityIds = activities.value.map((a) => a.id);
|
408 | 411 | const rows = data.rows.filter((a) => !activityIds.includes(a.id));
|
409 |
| - if (rows.length === 0) { |
| 412 | + if (rows.length >= props.entity.activityCount) { |
410 | 413 | noMore.value = true;
|
411 | 414 | }
|
412 | 415 | activities.value = reset ? rows : [...activities.value, ...rows];
|
413 | 416 |
|
414 |
| - timestamp.value = moment(data.rows.at(-1).timestamp).toISOString(); |
| 417 | + if (data.rows.length === 0) { |
| 418 | + timestamp.value = moment(timestamp.value).subtract(1, 'month').toISOString(); |
| 419 | + } else { |
| 420 | + timestamp.value = moment(data.rows.at(-1).timestamp).toISOString(); |
| 421 | + } |
415 | 422 | };
|
416 | 423 |
|
417 | 424 | const reloadActivities = async () => {
|
@@ -443,6 +450,10 @@ onMounted(async () => {
|
443 | 450 | await store.dispatch('integration/doFetch', segments.value.map((s) => s.id));
|
444 | 451 | await fetchActivities();
|
445 | 452 | });
|
| 453 | +
|
| 454 | +defineExpose({ |
| 455 | + fetchActivities, |
| 456 | +}); |
446 | 457 | </script>
|
447 | 458 |
|
448 | 459 | <script>
|
|
0 commit comments