[wccom-17942] Making sure snackbar doesn't appear before content has loaded.
- Fixing `prettier` linter errors.
This commit is contained in:
parent
6ae83b08ec
commit
6d65d54ed5
|
@ -1,5 +1,7 @@
|
||||||
export const DEFAULT_TAB_KEY = 'discover';
|
export const DEFAULT_TAB_KEY = 'discover';
|
||||||
export const MARKETPLACE_HOST = 'https://woocommerce.com';
|
export const MARKETPLACE_HOST = 'https://woocommerce.com';
|
||||||
export const MARKETPLACE_PATH = '/extensions';
|
export const MARKETPLACE_PATH = '/extensions';
|
||||||
export const MARKETPLACE_SEARCH_API_PATH = '/wp-json/wccom-extensions/1.0/search';
|
export const MARKETPLACE_SEARCH_API_PATH =
|
||||||
export const MARKETPLACE_CATEGORY_API_PATH = '/wp-json/wccom-extensions/1.0/categories';
|
'/wp-json/wccom-extensions/1.0/search';
|
||||||
|
export const MARKETPLACE_CATEGORY_API_PATH =
|
||||||
|
'/wp-json/wccom-extensions/1.0/categories';
|
||||||
|
|
|
@ -14,10 +14,7 @@ import { MarketplaceContext } from '../../contexts/marketplace-context';
|
||||||
import ProductListContent from '../product-list-content/product-list-content';
|
import ProductListContent from '../product-list-content/product-list-content';
|
||||||
import ProductLoader from '../product-loader/product-loader';
|
import ProductLoader from '../product-loader/product-loader';
|
||||||
import NoResults from '../product-list-content/no-results';
|
import NoResults from '../product-list-content/no-results';
|
||||||
import {
|
import { Product, SearchAPIProductType } from '../product-list/types';
|
||||||
Product,
|
|
||||||
SearchAPIProductType,
|
|
||||||
} from '../product-list/types';
|
|
||||||
import { MARKETPLACE_SEARCH_API_PATH, MARKETPLACE_HOST } from '../constants';
|
import { MARKETPLACE_SEARCH_API_PATH, MARKETPLACE_HOST } from '../constants';
|
||||||
|
|
||||||
export default function Extensions(): JSX.Element {
|
export default function Extensions(): JSX.Element {
|
||||||
|
@ -43,7 +40,8 @@ export default function Extensions(): JSX.Element {
|
||||||
|
|
||||||
const wccomSearchEndpoint =
|
const wccomSearchEndpoint =
|
||||||
MARKETPLACE_HOST +
|
MARKETPLACE_HOST +
|
||||||
MARKETPLACE_SEARCH_API_PATH + '?' +
|
MARKETPLACE_SEARCH_API_PATH +
|
||||||
|
'?' +
|
||||||
params.toString();
|
params.toString();
|
||||||
|
|
||||||
// Fetch data from WCCOM API
|
// Fetch data from WCCOM API
|
||||||
|
|
|
@ -83,8 +83,6 @@ export default function FeedbackModal(): JSX.Element {
|
||||||
const { createNotice } = useDispatch( 'core/notices' );
|
const { createNotice } = useDispatch( 'core/notices' );
|
||||||
|
|
||||||
function maybeShowSnackbar() {
|
function maybeShowSnackbar() {
|
||||||
let timer: ReturnType<typeof setTimeout> | undefined;
|
|
||||||
|
|
||||||
// Don't show if we're still loading content
|
// Don't show if we're still loading content
|
||||||
if ( isLoading ) {
|
if ( isLoading ) {
|
||||||
return;
|
return;
|
||||||
|
@ -104,12 +102,14 @@ export default function FeedbackModal(): JSX.Element {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
timer = setTimeout( showSnackbar, SNACKBAR_TIMEOUT );
|
const timer = setTimeout( showSnackbar, SNACKBAR_TIMEOUT );
|
||||||
|
|
||||||
// Without this, navigating between screens will create a series of snackbars
|
// Without this, navigating between screens will create a series of snackbars
|
||||||
dismissToday();
|
dismissToday();
|
||||||
|
|
||||||
return () => { clearTimeout( timer ); }
|
return () => {
|
||||||
|
clearTimeout( timer );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function showSnackbar() {
|
function showSnackbar() {
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
/**
|
/**
|
||||||
* External dependencies
|
* External dependencies
|
||||||
*/
|
*/
|
||||||
import { WooFooterItem } from '@woocommerce/admin-layout';
|
|
||||||
import { __ } from '@wordpress/i18n';
|
import { __ } from '@wordpress/i18n';
|
||||||
import { check, commentContent, shield } from '@wordpress/icons';
|
import { check, commentContent, shield } from '@wordpress/icons';
|
||||||
import { createInterpolateElement } from '@wordpress/element';
|
import { createInterpolateElement } from '@wordpress/element';
|
||||||
|
|
|
@ -108,11 +108,6 @@ const Tabs = ( props: TabsProps ): JSX.Element => {
|
||||||
const marketplaceContextValue = useContext( MarketplaceContext );
|
const marketplaceContextValue = useContext( MarketplaceContext );
|
||||||
const { setSelectedTab } = marketplaceContextValue;
|
const { setSelectedTab } = marketplaceContextValue;
|
||||||
|
|
||||||
interface Query {
|
|
||||||
path?: string;
|
|
||||||
tab?: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
const query: Record< string, string > = useQuery();
|
const query: Record< string, string > = useQuery();
|
||||||
|
|
||||||
useEffect( () => {
|
useEffect( () => {
|
||||||
|
|
|
@ -26,7 +26,7 @@ export function MarketplaceContextProvider( props: {
|
||||||
isLoading,
|
isLoading,
|
||||||
setIsLoading,
|
setIsLoading,
|
||||||
selectedTab,
|
selectedTab,
|
||||||
setSelectedTab
|
setSelectedTab,
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
|
@ -7,7 +7,10 @@ import apiFetch from '@wordpress/api-fetch';
|
||||||
* Internal dependencies
|
* Internal dependencies
|
||||||
*/
|
*/
|
||||||
import { Product } from '../components/product-list/types';
|
import { Product } from '../components/product-list/types';
|
||||||
import { MARKETPLACE_HOST, MARKETPLACE_CATEGORY_API_PATH } from '../components/constants';
|
import {
|
||||||
|
MARKETPLACE_HOST,
|
||||||
|
MARKETPLACE_CATEGORY_API_PATH
|
||||||
|
} from '../components/constants';
|
||||||
import { CategoryAPIItem } from '../components/category-selector/types';
|
import { CategoryAPIItem } from '../components/category-selector/types';
|
||||||
import { LOCALE } from '../../utils/admin-settings';
|
import { LOCALE } from '../../utils/admin-settings';
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue