Skip to content

Commit

Permalink
feat: always fetch response when MRF is enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
wanlingt committed Dec 26, 2023
1 parent 3a924e9 commit 834fde6
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import { useParams } from 'react-router-dom'

import { useToast } from '~hooks/useToast'

import { useUser } from '~features/user/queries'

import { getDecryptedSubmissionById } from '../AdminSubmissionsService'
import { adminFormResponsesKeys } from '../queries'
import { useStorageResponsesContext } from '../ResponsesPage/storage'
Expand All @@ -16,6 +18,9 @@ export const useIndividualSubmission = () => {
})

const { formId, submissionId } = useParams()
const { user } = useUser()
const displayWorkflow = user?.betaFlags?.mrf

if (!formId || !submissionId) {
throw new Error('No formId or submissionId provided')
}
Expand All @@ -26,8 +31,8 @@ export const useIndividualSubmission = () => {
adminFormResponsesKeys.individual(formId, submissionId),
() => getDecryptedSubmissionById({ formId, submissionId, secretKey }),
{
// Will never update once fetched.
staleTime: Infinity,
// For users with MRF enabled, will always fetch the response. Otherwise, response Will never update once fetched.
staleTime: displayWorkflow ? 0 : Infinity,
enabled: !!secretKey,
onError: (e) => {
toast({
Expand Down

0 comments on commit 834fde6

Please sign in to comment.