From 3200e3cf79ed60cb6c52f4c538627b04039adf23 Mon Sep 17 00:00:00 2001 From: MartinBraquet Date: Mon, 9 Mar 2026 12:12:40 +0100 Subject: [PATCH] Fix index and total not refreshing --- .../answer-compatibility-question-button.tsx | 7 ++++++- .../answer-compatibility-question-content.tsx | 21 +++++-------------- 2 files changed, 11 insertions(+), 17 deletions(-) diff --git a/web/components/answers/answer-compatibility-question-button.tsx b/web/components/answers/answer-compatibility-question-button.tsx index a48854bc..fd2b0fc2 100644 --- a/web/components/answers/answer-compatibility-question-button.tsx +++ b/web/components/answers/answer-compatibility-question-button.tsx @@ -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('random') + useEffect(() => { + refreshCompatibilityAll() + setQuestionIndex(0) + }, [sort]) + const sortedQuestions = useMemo(() => { return [...otherQuestions].sort((a, b) => { return compareBySort(a, b, sort) diff --git a/web/components/answers/answer-compatibility-question-content.tsx b/web/components/answers/answer-compatibility-question-content.tsx index 448d52dc..d3a150fe 100644 --- a/web/components/answers/answer-compatibility-question-content.tsx +++ b/web/components/answers/answer-compatibility-question-content.tsx @@ -157,22 +157,6 @@ export function AnswerCompatibilityQuestionContent(props: { return ( - {/*{compatibilityQuestion.importance_score > 0 && */} - {/* */} - {/* Massive upgrade coming soon! More prompts, better predictive power, filtered by category, etc.*/} - {/* */} - {/*}*/} - {index !== null && - index !== undefined && - total !== null && - total !== undefined && - total > 1 && ( - - - {index + 1} / {total} - - - )} {shortenedPopularity && ( )} + {isFinite(index!) && isFinite(total!) && ( + + {index! + 1} / {total} + + )} {sort && setSort && (