Fix index and total not refreshing

This commit is contained in:
MartinBraquet
2026-03-09 12:12:40 +01:00
parent de9c28965f
commit 3200e3cf79
2 changed files with 11 additions and 17 deletions

View File

@@ -2,7 +2,7 @@ import clsx from 'clsx'
import {User} from 'common/user'
import Link from 'next/link'
import router from 'next/router'
import {useMemo, useState} from 'react'
import {useEffect, useMemo, useState} from 'react'
import toast from 'react-hot-toast'
import {Button} from 'web/components/buttons/button'
import {compareBySort, CompatibilitySort} from 'web/components/compatibility/sort-widget'
@@ -167,6 +167,11 @@ function AnswerCompatibilityQuestionModal(props: {
const [showOnboarding, setShowOnboarding] = useState(fromSignup ?? false)
const [sort, setSort] = useState<CompatibilitySort>('random')
useEffect(() => {
refreshCompatibilityAll()
setQuestionIndex(0)
}, [sort])
const sortedQuestions = useMemo(() => {
return [...otherQuestions].sort((a, b) => {
return compareBySort(a, b, sort)

View File

@@ -157,22 +157,6 @@ export function AnswerCompatibilityQuestionContent(props: {
return (
<Col className="min-h-0 w-full gap-4">
<Col className="gap-1 shrink-0">
{/*{compatibilityQuestion.importance_score > 0 && <Row className="text-blue-400 -mt-4 w-full justify-start text-sm">*/}
{/* <span>*/}
{/* Massive upgrade coming soon! More prompts, better predictive power, filtered by category, etc.*/}
{/* </span>*/}
{/*</Row>}*/}
{index !== null &&
index !== undefined &&
total !== null &&
total !== undefined &&
total > 1 && (
<Row className="text-ink-500 -mt-4 w-full justify-end text-sm">
<span>
<span className="text-ink-600 font-semibold">{index + 1}</span> / {total}
</span>
</Row>
)}
<Row>
{shortenedPopularity && (
<Tooltip
@@ -188,6 +172,11 @@ export function AnswerCompatibilityQuestionContent(props: {
</Row>
</Tooltip>
)}
{isFinite(index!) && isFinite(total!) && (
<span className={'ml-16 text-sm'}>
<span className="text-ink-600 font-semibold">{index! + 1}</span> / {total}
</span>
)}
{sort && setSort && (
<CompatibilitySortWidget
className="text-sm sm:flex ml-auto"