From 33e7aa6e362673549b620f76521f88a195d81295 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20Kv=C3=A1=C4=8Dek?= Date: Tue, 6 Jan 2026 22:02:24 +0100 Subject: [PATCH] lepsi infinite scroll --- src/components/FAB.vue | 7 +- src/components/ListFilters.vue | 19 ++- src/components/LoadMoreList.vue | 41 ------ src/components/PrimaryAction.vue | 46 ++++++ src/components/aircrafts/AircraftsList.vue | 97 ++++++------ .../flightPlans/FlightPlansList.vue | 60 +++++--- src/components/flights/FlightsList.vue | 139 ++++++++---------- src/components/poi/POIList.vue | 76 ++++------ src/composables/pagination.js | 64 +++++++- src/graphql/fragments/flight.js | 1 - src/graphql/queries/aircrafts.js | 6 +- src/graphql/queries/flightPlan.js | 13 +- src/graphql/queries/flights.js | 3 +- src/pages/profile/aircraft/AircraftsPage.vue | 28 ++-- src/pages/profile/flight/FlightsPage.vue | 27 ++-- .../profile/flightPlanner/FlightPlansPage.vue | 25 +++- .../profile/poi/PointsOfInterestPage.vue | 29 ++-- src/pages/public/poi/PointsOfInterestPage.vue | 20 +-- src/stores/Aircrafts.js | 7 +- src/stores/FlightPlans.js | 16 +- src/stores/Flights.js | 3 + src/stores/PointsOfInterest.js | 2 +- 22 files changed, 381 insertions(+), 348 deletions(-) delete mode 100644 src/components/LoadMoreList.vue create mode 100644 src/components/PrimaryAction.vue diff --git a/src/components/FAB.vue b/src/components/FAB.vue index e8b9dc9..821e764 100644 --- a/src/components/FAB.vue +++ b/src/components/FAB.vue @@ -13,7 +13,6 @@ const props = defineProps({ }) const config = computed(() => { - if (props.mode === "add") { return {icon: "add", label: "Přidat"}; } else if (props.mode === "edit") { @@ -26,7 +25,11 @@ const config = computed(() => { diff --git a/src/components/ListFilters.vue b/src/components/ListFilters.vue index 0679089..80709e8 100644 --- a/src/components/ListFilters.vue +++ b/src/components/ListFilters.vue @@ -38,14 +38,23 @@ onMounted(() => { if (search) { filters.value.search = search; + } else { + filters.value = {}; } }) diff --git a/src/components/LoadMoreList.vue b/src/components/LoadMoreList.vue deleted file mode 100644 index 63a9eee..0000000 --- a/src/components/LoadMoreList.vue +++ /dev/null @@ -1,41 +0,0 @@ - - - diff --git a/src/components/PrimaryAction.vue b/src/components/PrimaryAction.vue new file mode 100644 index 0000000..738cabd --- /dev/null +++ b/src/components/PrimaryAction.vue @@ -0,0 +1,46 @@ + + + + diff --git a/src/components/aircrafts/AircraftsList.vue b/src/components/aircrafts/AircraftsList.vue index 13e55ad..2d17393 100644 --- a/src/components/aircrafts/AircraftsList.vue +++ b/src/components/aircrafts/AircraftsList.vue @@ -1,68 +1,53 @@ diff --git a/src/components/flightPlans/FlightPlansList.vue b/src/components/flightPlans/FlightPlansList.vue index b1a59f1..456a440 100644 --- a/src/components/flightPlans/FlightPlansList.vue +++ b/src/components/flightPlans/FlightPlansList.vue @@ -1,36 +1,48 @@ diff --git a/src/components/flights/FlightsList.vue b/src/components/flights/FlightsList.vue index 7917684..4eb03c5 100644 --- a/src/components/flights/FlightsList.vue +++ b/src/components/flights/FlightsList.vue @@ -2,10 +2,7 @@ import {minutesToHumanReadable} from "src/composables/datetimeUtils"; import {flightName} from "src/composables/flight"; import AvatarFromPhoto from "components/avatars/AvatarFromPhoto.vue"; -import FlightsListSkeleton from "components/flights/skeletons/FlightsListSkeleton.vue"; -import {computed} from "vue"; -import LoadMoreList from "components/LoadMoreList.vue"; -import {pluralize} from "../../composables/utils"; +import {useInfiniteScroll} from "src/composables/pagination"; const props = defineProps({ items: { @@ -16,96 +13,82 @@ const props = defineProps({ type: Boolean, required: true }, - totalItemsCount: { - type: Number, - required: true - }, - itemsPerPage: { - type: Number, - required: false, - default: 5, - }, - isQueryRunning: { - type: Boolean, - required: false, - default: false - } + ...useInfiniteScroll().propsDef }); +const emits = defineEmits([...useInfiniteScroll().emitsDef]) +const {emitLoadMore, hasMoreData} = useInfiniteScroll(emits, props) + const routeDetail = (flight) => { if (props.public) return {name: "publicFlightDetail", params: {username: flight.pilot.publicUsername, flightSlug: flight.urlSlug}} else return {name: "flightDetail", params: {id: flight.id}} }; -const loadMoreCount = computed(() => { - return Math.min(props.itemsPerPage, props.totalItemsCount - props.items.length); -}); -