@@ -6,19 +6,30 @@ import { isSimpleSite } from '@automattic/jetpack-script-data';
66import { useAnalytics } from '@automattic/jetpack-shared-extension-utils' ;
77import requestExternalAccess from '@automattic/request-external-access' ;
88import { Button , Path , Spinner , SVG } from '@wordpress/components' ;
9+ import { useSelect , useDispatch } from '@wordpress/data' ;
910import { useCallback , useRef , useState } from '@wordpress/element' ;
1011import { __ , _x } from '@wordpress/i18n' ;
1112import clsx from 'clsx' ;
1213/**
1314 * Internal dependencies
1415 */
1516import { config } from '../..' ;
16- import { useIntegrationStatus } from '../../../blocks/contact-form/components/jetpack- integrations-modal/hooks/use-integration-status ' ;
17+ import { INTEGRATIONS_STORE } from '../../../store/ integrations' ;
1718import { PARTIAL_RESPONSES_PATH } from '../../../util/get-preferred-responses-view' ;
19+ /**
20+ * Internal dependencies
21+ */
22+ import type { SelectIntegrations , IntegrationsDispatch } from '../../../store/integrations' ;
23+ import type { Integration } from '../../../types' ;
1824
1925const GoogleDriveExport = ( { onExport, autoConnect = false } ) => {
2026 const [ isExporting , setIsExporting ] = useState ( false ) ;
21- const { integration, refreshStatus } = useIntegrationStatus ( 'google-drive' ) ;
27+ const { integration } = useSelect ( ( select : SelectIntegrations ) => {
28+ const store = select ( INTEGRATIONS_STORE ) ;
29+ const list = store . getIntegrations ( ) || [ ] ;
30+ return { integration : list . find ( ( i : Integration ) => i . id === 'google-drive' ) } ;
31+ } , [ ] ) as { integration ?: Integration } ;
32+ const { refreshIntegrations } = useDispatch ( INTEGRATIONS_STORE ) as IntegrationsDispatch ;
2233 const isConnectedToGoogleDrive = ! ! integration ?. isConnected ;
2334 const { tracks } = useAnalytics ( ) ;
2435 const autoConnectOpened = useRef ( false ) ;
@@ -58,12 +69,12 @@ const GoogleDriveExport = ( { onExport, autoConnect = false } ) => {
5869 setIsTogglingConnection ( true ) ;
5970 requestExternalAccess ( integration ?. settingsUrl , ( { keyring_id : keyringId } ) => {
6071 if ( keyringId ) {
61- refreshStatus ( ) ;
72+ refreshIntegrations ( ) ;
6273 } else {
6374 setIsTogglingConnection ( false ) ;
6475 }
6576 } ) ;
66- } , [ tracks , integration ?. settingsUrl , refreshStatus ] ) ;
77+ } , [ tracks , integration ?. settingsUrl , refreshIntegrations ] ) ;
6778
6879 if ( isOfflineMode ) {
6980 return null ;
0 commit comments