Skip to content

Commit

Permalink
Added requested changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Amit Dave committed Apr 30, 2024
1 parent cf2c766 commit f5d7083
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 9 deletions.
2 changes: 1 addition & 1 deletion packages/cypress/src/integration/questions/read.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ describe('[Questions]', () => {

cy.step('Can visit question')
cy.visit(`/questions/${question.slug}`)
cy.title().should('eq', question.title);
cy.title().should('eq', question.title)

cy.step('All metadata visible')
cy.contains(`${question.subscribers.length} following`)
Expand Down
1 change: 1 addition & 0 deletions src/pages/Question/QuestionListing.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export const QuestionListing = () => {
const sort = searchParams.get('sort') as QuestionSortOptions

useEffect(() => {
document.title = 'Questions'
if (!sort) {
// ensure sort is set
const params = new URLSearchParams(searchParams.toString())
Expand Down
11 changes: 3 additions & 8 deletions src/pages/Question/QuestionPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import { TagList } from 'src/common/Tags/TagsList'
import { useQuestionStore } from 'src/stores/Question/question.store'
import { formatImagesForGallery } from 'src/utils/formatImageListForGallery'
import { buildStatisticsLabel } from 'src/utils/helpers'
import { incrementViewCount } from 'src/utils/incrementViewCount'
import { Box, Button, Card, Divider, Flex, Heading, Text } from 'theme-ui'

import { ContentAuthorTimestamp } from '../common/ContentAuthorTimestamp/ContentAuthorTimestamp'
Expand Down Expand Up @@ -49,13 +48,10 @@ export const QuestionPage = () => {
}

store.activeQuestionItem = foundQuestion
incrementViewCount({
document: foundQuestion,
documentType: 'question',
store,
})
store.incrementViewCount(foundQuestion._id)

setQuestion(foundQuestion)
document.title = foundQuestion.title
setIsLoading(false)
}

Expand All @@ -82,7 +78,6 @@ export const QuestionPage = () => {
<Loader />
) : question ? (
<>
{document.title = question.title}
<Card sx={{ position: 'relative', marginTop: 4 }}>
<Flex sx={{ flexDirection: 'column', padding: 4, gap: 2 }}>
<Flex sx={{ flexWrap: 'wrap', gap: 2 }}>
Expand Down Expand Up @@ -161,7 +156,7 @@ export const QuestionPage = () => {
{
icon: 'view',
label: buildStatisticsLabel({
stat: question.total_views,
stat: question.total_views || 0,
statUnit: 'view',
usePlural: true,
}),
Expand Down

0 comments on commit f5d7083

Please sign in to comment.