From 78cdb592c54206624f51ebe89c7c324c9d6cca43 Mon Sep 17 00:00:00 2001 From: wvffle Date: Sat, 25 Jun 2022 22:29:53 +0000 Subject: [PATCH] Cleanup defaultPaginateBy and fix onMounted missing from imports --- front/src/components/favorites/List.vue | 6 ++---- front/src/components/library/Albums.vue | 4 +--- front/src/components/library/Artists.vue | 6 ++---- front/src/components/library/Podcasts.vue | 6 ++---- front/src/components/library/Radios.vue | 6 ++---- front/src/composables/useOrdering.ts | 5 +---- front/src/router/index.ts | 12 +----------- front/src/views/playlists/List.vue | 6 ++---- 8 files changed, 13 insertions(+), 38 deletions(-) diff --git a/front/src/components/favorites/List.vue b/front/src/components/favorites/List.vue index 19182e524..78d43fc9c 100644 --- a/front/src/components/favorites/List.vue +++ b/front/src/components/favorites/List.vue @@ -17,12 +17,10 @@ import { OrderingField } from '~/store/ui' interface Props extends OrderingProps { defaultPage?: number - defaultPaginateBy?: number } const props = withDefaults(defineProps(), { - defaultPage: 1, - defaultPaginateBy: 1 + defaultPage: 1 }) const store = useStore() @@ -42,7 +40,7 @@ const logger = useLogger() const sharedLabels = useSharedLabels() const router = useRouter() -const { onOrderingUpdate, orderingString, paginateBy, ordering, orderingDirection } = useOrdering(props.orderingConfigName, props.defaultPaginateBy) +const { onOrderingUpdate, orderingString, paginateBy, ordering, orderingDirection } = useOrdering(props.orderingConfigName) const updateQueryString = () => router.replace({ query: { diff --git a/front/src/components/library/Albums.vue b/front/src/components/library/Albums.vue index 750489eba..ef7abbb46 100644 --- a/front/src/components/library/Albums.vue +++ b/front/src/components/library/Albums.vue @@ -17,7 +17,6 @@ import { useStore } from '~/store' interface Props extends OrderingProps { defaultPage?: number - defaultPaginateBy?: number defaultQuery?: string defaultTags?: string[] scope?: string @@ -25,7 +24,6 @@ interface Props extends OrderingProps { const props = withDefaults(defineProps(), { defaultPage: 1, - defaultPaginateBy: 1, defaultQuery: '', defaultTags: () => [], scope: 'all' @@ -47,7 +45,7 @@ const orderingOptions: [OrderingField, keyof typeof sharedLabels.filters][] = [ const logger = useLogger() const sharedLabels = useSharedLabels() -const { onOrderingUpdate, orderingString, paginateBy, ordering, orderingDirection } = useOrdering(props.orderingConfigName, props.defaultPaginateBy) +const { onOrderingUpdate, orderingString, paginateBy, ordering, orderingDirection } = useOrdering(props.orderingConfigName) const router = useRouter() const updateQueryString = () => router.replace({ diff --git a/front/src/components/library/Artists.vue b/front/src/components/library/Artists.vue index cfbde8db0..361b12bdb 100644 --- a/front/src/components/library/Artists.vue +++ b/front/src/components/library/Artists.vue @@ -9,7 +9,7 @@ import TagsSelector from '~/components/library/TagsSelector.vue' import useLogger from '~/composables/useLogger' import useSharedLabels from '~/composables/locale/useSharedLabels' import { OrderingField } from '~/store/ui' -import { computed, reactive, ref, watch } from 'vue' +import { computed, reactive, ref, watch, onMounted } from 'vue' import { useGettext } from 'vue3-gettext' import { useStore } from '~/store' import useOrdering, { OrderingProps } from '~/composables/useOrdering' @@ -17,7 +17,6 @@ import { onBeforeRouteUpdate, useRouter } from 'vue-router' interface Props extends OrderingProps { defaultPage?: number - defaultPaginateBy?: number defaultQuery?: string defaultTags?: string[] scope?: string @@ -25,7 +24,6 @@ interface Props extends OrderingProps { const props = withDefaults(defineProps(), { defaultPage: 1, - defaultPaginateBy: 1, defaultQuery: '', defaultTags: () => [], scope: 'all' @@ -47,7 +45,7 @@ const orderingOptions: [OrderingField, keyof typeof sharedLabels.filters][] = [ const logger = useLogger() const sharedLabels = useSharedLabels() -const { onOrderingUpdate, orderingString, paginateBy, ordering, orderingDirection } = useOrdering(props.orderingConfigName, props.defaultPaginateBy) +const { onOrderingUpdate, orderingString, paginateBy, ordering, orderingDirection } = useOrdering(props.orderingConfigName) const router = useRouter() const updateQueryString = () => router.replace({ diff --git a/front/src/components/library/Podcasts.vue b/front/src/components/library/Podcasts.vue index 45d3c67cb..75e319acf 100644 --- a/front/src/components/library/Podcasts.vue +++ b/front/src/components/library/Podcasts.vue @@ -11,7 +11,7 @@ import RemoteSearchForm from '~/components/RemoteSearchForm.vue' import useLogger from '~/composables/useLogger' import useSharedLabels from '~/composables/locale/useSharedLabels' import { OrderingField } from '~/store/ui' -import { computed, reactive, ref, watch } from 'vue' +import { computed, reactive, ref, watch, onMounted } from 'vue' import useOrdering, { OrderingProps } from '~/composables/useOrdering' import { useGettext } from 'vue3-gettext' import { useStore } from '~/store' @@ -19,7 +19,6 @@ import { onBeforeRouteUpdate, useRouter } from 'vue-router' interface Props extends OrderingProps { defaultPage?: number - defaultPaginateBy?: number defaultQuery?: string defaultTags?: string[] @@ -28,7 +27,6 @@ interface Props extends OrderingProps { const props = withDefaults(defineProps(), { defaultPage: 1, - defaultPaginateBy: 1, defaultQuery: '', defaultTags: () => [], scope: 'all' @@ -50,7 +48,7 @@ const orderingOptions: [OrderingField, keyof typeof sharedLabels.filters][] = [ const logger = useLogger() const sharedLabels = useSharedLabels() -const { onOrderingUpdate, orderingString, paginateBy, ordering, orderingDirection } = useOrdering(props.orderingConfigName, props.defaultPaginateBy) +const { onOrderingUpdate, orderingString, paginateBy, ordering, orderingDirection } = useOrdering(props.orderingConfigName) const router = useRouter() const updateQueryString = () => router.replace({ diff --git a/front/src/components/library/Radios.vue b/front/src/components/library/Radios.vue index 66145898c..e7157f27b 100644 --- a/front/src/components/library/Radios.vue +++ b/front/src/components/library/Radios.vue @@ -7,7 +7,7 @@ import Pagination from '~/components/vui/Pagination.vue' import useLogger from '~/composables/useLogger' import useSharedLabels from '~/composables/locale/useSharedLabels' import { OrderingField } from '~/store/ui' -import { computed, ref, watch } from 'vue' +import { computed, ref, watch, onMounted } from 'vue' import { useGettext } from 'vue3-gettext' import { useStore } from '~/store' import { onBeforeRouteUpdate, useRouter } from 'vue-router' @@ -15,7 +15,6 @@ import useOrdering, { OrderingProps } from '~/composables/useOrdering' interface Props extends OrderingProps { defaultPage?: number - defaultPaginateBy?: number defaultQuery?: string scope?: string @@ -23,7 +22,6 @@ interface Props extends OrderingProps { const props = withDefaults(defineProps(), { defaultPage: 1, - defaultPaginateBy: 1, defaultQuery: '', scope: 'all' }) @@ -42,7 +40,7 @@ const orderingOptions: [OrderingField, keyof typeof sharedLabels.filters][] = [ const logger = useLogger() const sharedLabels = useSharedLabels() -const { onOrderingUpdate, orderingString, paginateBy, ordering, orderingDirection } = useOrdering(props.orderingConfigName, props.defaultPaginateBy) +const { onOrderingUpdate, orderingString, paginateBy, ordering, orderingDirection } = useOrdering(props.orderingConfigName) const router = useRouter() const updateQueryString = () => router.replace({ diff --git a/front/src/composables/useOrdering.ts b/front/src/composables/useOrdering.ts index 86d6f4857..e275825a9 100644 --- a/front/src/composables/useOrdering.ts +++ b/front/src/composables/useOrdering.ts @@ -8,7 +8,7 @@ export interface OrderingProps { orderingConfigName: RouteWithPreferences | null } -export default (orderingConfigName: MaybeRef, defaultPaginateBy?: MaybeRef) => { +export default (orderingConfigName: MaybeRef) => { const store = useStore() const route = useRoute() @@ -18,9 +18,6 @@ export default (orderingConfigName: MaybeRef, defau }) const { paginateBy, ordering, orderingDirection } = toRefs(config) - if (defaultPaginateBy !== undefined) { - paginateBy.value = unref(defaultPaginateBy) - } const orderingString = computed(() => { if (orderingDirection.value === '-') return `-${ordering.value}` diff --git a/front/src/router/index.ts b/front/src/router/index.ts index bce8b722c..37ae28642 100644 --- a/front/src/router/index.ts +++ b/front/src/router/index.ts @@ -240,8 +240,7 @@ export default createRouter({ import('~/components/favorites/List.vue'), props: route => ({ defaultOrdering: route.query.ordering, - defaultPage: route.query.page, - defaultPaginateBy: route.query.paginateBy + defaultPage: route.query.page }) }, { @@ -635,7 +634,6 @@ export default createRouter({ defaultTags: Array.isArray(route.query.tag || []) ? route.query.tag : [route.query.tag], - defaultPaginateBy: route.query.paginateBy, defaultPage: route.query.page }) }, @@ -653,7 +651,6 @@ export default createRouter({ defaultTags: Array.isArray(route.query.tag || []) ? route.query.tag : [route.query.tag], - defaultPaginateBy: route.query.paginateBy, defaultPage: route.query.page }) }, @@ -670,7 +667,6 @@ export default createRouter({ defaultTags: Array.isArray(route.query.tag || []) ? route.query.tag : [route.query.tag], - defaultPaginateBy: route.query.paginateBy, defaultPage: route.query.page }) }, @@ -687,7 +683,6 @@ export default createRouter({ defaultTags: Array.isArray(route.query.tag || []) ? route.query.tag : [route.query.tag], - defaultPaginateBy: route.query.paginateBy, defaultPage: route.query.page }) }, @@ -705,7 +700,6 @@ export default createRouter({ defaultTags: Array.isArray(route.query.tag || []) ? route.query.tag : [route.query.tag], - defaultPaginateBy: route.query.paginateBy, defaultPage: route.query.page }) }, @@ -719,7 +713,6 @@ export default createRouter({ props: route => ({ defaultOrdering: route.query.ordering, defaultQuery: route.query.query, - defaultPaginateBy: route.query.paginateBy, defaultPage: route.query.page }) }, @@ -734,7 +727,6 @@ export default createRouter({ scope: 'me', defaultOrdering: route.query.ordering, defaultQuery: route.query.query, - defaultPaginateBy: route.query.paginateBy, defaultPage: route.query.page }) }, @@ -771,7 +763,6 @@ export default createRouter({ props: route => ({ defaultOrdering: route.query.ordering, defaultQuery: route.query.query, - defaultPaginateBy: route.query.paginateBy, defaultPage: route.query.page }) }, @@ -784,7 +775,6 @@ export default createRouter({ scope: 'me', defaultOrdering: route.query.ordering, defaultQuery: route.query.query, - defaultPaginateBy: route.query.paginateBy, defaultPage: route.query.page }) }, diff --git a/front/src/views/playlists/List.vue b/front/src/views/playlists/List.vue index 915625eed..c69390319 100644 --- a/front/src/views/playlists/List.vue +++ b/front/src/views/playlists/List.vue @@ -2,7 +2,7 @@ import axios from 'axios' import $ from 'jquery' import qs from 'qs' -import { computed, ref, watch } from 'vue' +import { computed, ref, watch, onMounted } from 'vue' import { useRouter, onBeforeRouteUpdate } from 'vue-router' import { useGettext } from 'vue3-gettext' @@ -15,14 +15,12 @@ import { OrderingField } from '~/store/ui' interface Props extends OrderingProps { defaultPage?: number - defaultPaginateBy?: number defaultQuery?: string scope?: string } const props = withDefaults(defineProps(), { defaultPage: 1, - defaultPaginateBy: 1, defaultQuery: '', scope: 'all' }) @@ -42,7 +40,7 @@ const orderingOptions: [OrderingField, keyof typeof sharedLabels.filters][] = [ const logger = useLogger() const sharedLabels = useSharedLabels() -const { onOrderingUpdate, orderingString, paginateBy, ordering, orderingDirection } = useOrdering(props.orderingConfigName, props.defaultPaginateBy) +const { onOrderingUpdate, orderingString, paginateBy, ordering, orderingDirection } = useOrdering(props.orderingConfigName) const router = useRouter() const updateQueryString = () => router.replace({