Skip to content
This repository has been archived by the owner on May 20, 2024. It is now read-only.

Commit

Permalink
Support public activity query params (#2713)
Browse files Browse the repository at this point in the history
* Support public activity query params

For:
- place
- activity type

* Linting fix

* Delete flakey unused cordova test
  • Loading branch information
nicksellen authored Mar 19, 2024
1 parent 3b2b77e commit 15b8ed8
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 62 deletions.
6 changes: 5 additions & 1 deletion src/activities/queries.js
Original file line number Diff line number Diff line change
Expand Up @@ -273,13 +273,17 @@ export function useICSTokenQuery (queryOptions) {
export function usePublicActivityListQuery ({
groupId,
dateMin,
placeId,
activityTypeId,
pageSize = 10,
}, queryOptions = {}) {
const query = useInfiniteQuery(
queryKeyActivityList({ groupId, dateMin }),
queryKeyActivityList({ groupId, dateMin, placeId, activityTypeId }),
({ pageParam }) => api.listPublic({
group: unref(groupId),
dateMin: unref(dateMin),
place: unref(placeId),
activityType: unref(activityTypeId),
cursor: pageParam,
pageSize,
}),
Expand Down
60 changes: 0 additions & 60 deletions src/authuser/api/auth.spec.js

This file was deleted.

3 changes: 3 additions & 0 deletions src/base/routes/embed.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,8 @@ export default [
name: 'publicActivitiesEmbed',
path: '/embed/public-activities/:groupId',
component: PublicActivitiesEmbed,
meta: {
noRedirect: true,
},
},
]
5 changes: 5 additions & 0 deletions src/base/services.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,11 @@ export const useRoutingLogic = defineService(() => {
router.beforeEach(async (to, from, nextFn) => {
let next

if (to.meta.noRedirect) {
nextFn()
return
}

await waitForUserToLoad()

const requiredGroupFeatures = to.matched.map(m => m.meta.requireFeature).filter(Boolean)
Expand Down
6 changes: 5 additions & 1 deletion src/group/services.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { extend } from 'quasar'
import { computed, watch, ref, readonly, watchEffect } from 'vue'
import { useRouter } from 'vue-router'
import { useRoute, useRouter } from 'vue-router'

import { useSaveUserMutation } from '@/authuser/mutations'
import { useAuthService } from '@/authuser/services'
Expand Down Expand Up @@ -37,6 +37,8 @@ export const useCurrentGroupService = defineService(() => {
clearGroup,
} = useCurrentGroupId()

const route = useRoute()

const { groups } = useGroupInfoService()

const {
Expand All @@ -46,6 +48,8 @@ export const useCurrentGroupService = defineService(() => {
} = useGroupDetailQuery({ groupId }, {
onError (error) {
if (error?.response?.status === 404) { // TODO: could do for other errors too?
if (route.meta.noRedirect) return

// Not found! (only groups we are members of can be found) .. but it might exist for preview
const groupPreview = groups.value.find(group => group.id === groupId.value)
if (groupPreview) {
Expand Down
9 changes: 9 additions & 0 deletions src/groupInfo/pages/PublicActivitiesEmbed.vue
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ import {
QItemSection,
QItemLabel,
} from 'quasar'
import { computed } from 'vue'
import { useRoute } from 'vue-router'
import { useActivityTypeHelpers } from '@/activities/helpers'
import { usePublicActivityListQuery } from '@/activities/queries'
Expand All @@ -83,12 +85,19 @@ const { getIconProps, getTranslatedName } = useActivityTypeHelpers()
const groupId = useIntegerRouteParam('groupId')
const route = useRoute()
const placeId = computed(() => route.query.place)
const activityTypeId = computed(() => route.query.type)
const {
publicActivities,
infiniteScroll,
} = usePublicActivityListQuery({
groupId,
dateMin: newDateRoundedTo5Minutes(),
placeId,
activityTypeId,
})
function getBannerImageUrl (publicActivity) {
Expand Down

0 comments on commit 15b8ed8

Please sign in to comment.