Skip to content

Commit

Permalink
Kim/search issues (#203)
Browse files Browse the repository at this point in the history
* Check if it's a wagtail image or a simplecast image

* deepsource fixes
  • Loading branch information
kimlarocca authored Mar 1, 2024
1 parent 3ed41b7 commit 563abe8
Showing 1 changed file with 32 additions and 33 deletions.
65 changes: 32 additions & 33 deletions components/EpisodesAlgolia.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import VFlexibleLink from '@nypublicradio/nypr-design-system-vue3/v2/src/compone
const route = useRoute()
const props = defineProps({
const props = defineProps( {
header: {
type: String,
default: null,
Expand Down Expand Up @@ -49,75 +49,72 @@ const props = defineProps({
type: Object,
default: null,
},
})
} )
const emit = defineEmits(['searchPageEvent'])
const emit = defineEmits( [ 'searchPageEvent' ] )
const dataLoaded = ref(false)
const episodes = ref([])
const totalCount = ref(null)
const startPageNumber = ref(props.startPage)
const cardsPerRow = ref(3) // based on grid col-4 on (>= lg breakpoint)
const dataLoaded = ref( false )
const episodes = ref( [] )
const totalCount = ref( null )
const startPageNumber = ref( props.startPage )
const cardsPerRow = ref( 3 ) // based on grid col-4 on (>= lg breakpoint)
const rowsPerAdArr = []
onMounted(() => {
onMounted( () => {
let currentCardsPerRow = cardsPerRow.value
// when less than breakpoint.lg, we are showing 2 cards per row, update currentCardsPerRow var
if (window.innerWidth <= breakpoint.lg) {
if ( window.innerWidth <= breakpoint.lg ) {
currentCardsPerRow = 2
}
// get the total number of ads that will show in the current layout
const numOfAds =
cardCountCalc.value / props.rowsPerAd / currentCardsPerRow +
(props.showLastAd ? 1 : 0)
( props.showLastAd ? 1 : 0 )
// loop through the number of ads and push number where the add will populate to the rowsPerAdArr
for (let i = 1; i < numOfAds; i++) {
for ( let i = 1; i < numOfAds; i++ ) {
const adPoint = i * props.rowsPerAd * currentCardsPerRow
rowsPerAdArr.push(adPoint)
rowsPerAdArr.push( adPoint )
}
// temp data loaded
dataLoaded.value = true
})
} )
// checks if the index is where we should populate an ad
const insertAD = (index) => {
return rowsPerAdArr.includes(index)
const insertAD = ( index ) => {
return rowsPerAdArr.includes( index )
}
/*
func to determin how many cards to show
*/
const cardCountCalc = computed(() => {
const cardCountCalc = computed( () => {
return props.startCount
? props.startCount + props.rowCount * cardsPerRow.value
: props.rowCount * cardsPerRow.value // (3 cards per )
})
} )
// handle the episodes array based on startCount and buckeltlimit props
const getEpisodes = computed(() => {})
onBeforeMount(async () => {
onBeforeMount( () => {
// if the url query page has a value, set the startPageNumber to that value
if (route.query.page) {
if ( route.query.page ) {
startPageNumber.value = route.query.page
}
})
} )
// a watcher to update the route page query when startPageNumber changes
watch(startPageNumber, (page, prev) => {
navigateTo({
watch( startPageNumber, ( page ) => {
navigateTo( {
query: { page: page },
})
})
} )
} )
async function onPage(event) {
async function onPage ( event ) {
//event.page: New page number
//event.first: Index of first record
//event.rows: Number of rows to display in new page
//event.pageCount: Total number of pages
emit('searchPageEvent', event)
emit( 'searchPageEvent', event )
//dataLoaded.value = false
}
</script>
Expand Down Expand Up @@ -155,9 +152,11 @@ async function onPage(event) {
<client-only>
<v-card
:image="
formatPublisherImageUrl(
episode['image-main'].template
)
episode['image-main'].template
? formatPublisherImageUrl(
episode['image-main'].template
)
: episode['image-main'].url
"
:width="320"
:height="240"
Expand Down

0 comments on commit 563abe8

Please sign in to comment.