diff --git a/projects/plugins/protect/changelog/fix-protect-credentials-refetch-interval b/projects/plugins/protect/changelog/fix-protect-credentials-refetch-interval new file mode 100644 index 0000000000000..3ae06ab163288 --- /dev/null +++ b/projects/plugins/protect/changelog/fix-protect-credentials-refetch-interval @@ -0,0 +1,5 @@ +Significance: patch +Type: fixed +Comment: Fixed background refreshing of data when credentials modal opened. + + diff --git a/projects/plugins/protect/src/js/data/use-credentials-query.ts b/projects/plugins/protect/src/js/data/use-credentials-query.ts index 431f5c9045751..a5d2ddc8cc703 100644 --- a/projects/plugins/protect/src/js/data/use-credentials-query.ts +++ b/projects/plugins/protect/src/js/data/use-credentials-query.ts @@ -6,14 +6,9 @@ import { QUERY_CREDENTIALS_KEY } from '../constants'; /** * Credentials Query Hook * - * @param {object} args - Args. - * @param {boolean} args.usePolling - Use polling. - * * @return {UseQueryResult} useQuery result. */ -export default function useCredentialsQuery( { - usePolling, -}: { usePolling?: boolean } = {} ): UseQueryResult< [ Record< string, unknown > ] > { +export default function useCredentialsQuery(): UseQueryResult< [ Record< string, unknown > ] > { const { isRegistered } = useConnection( { autoTrigger: false, from: 'protect', @@ -25,19 +20,6 @@ export default function useCredentialsQuery( { queryKey: [ QUERY_CREDENTIALS_KEY ], queryFn: API.checkCredentials, initialData: window?.jetpackProtectInitialState?.credentials, - refetchInterval: query => { - if ( ! usePolling ) { - return false; - } - if ( ! query.state.data ) { - return false; - } - if ( query.state.data?.length ) { - return false; - } - - return 5_000; - }, enabled: isRegistered, } ); }