Keep showing product editor feedback bar after feedback modal shown (#38773)

* Show feedback bar even after feedback is given

* Changelog
This commit is contained in:
Matt Sherman 2023-06-16 11:51:18 -04:00 committed by GitHub
parent 71a039852f
commit 9a6d9533c9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 36 deletions

View File

@ -0,0 +1,4 @@
Significance: patch
Type: enhancement
Show feedback bar even after feedback is given.

View File

@ -2,49 +2,35 @@
* External dependencies
*/
import { resolveSelect, useDispatch, useSelect } from '@wordpress/data';
import { useCustomerEffortScoreModal } from '@woocommerce/customer-effort-score';
import { OPTIONS_STORE_NAME } from '@woocommerce/data';
/**
* Internal dependencies
*/
import {
PRODUCT_EDITOR_SHOW_FEEDBACK_BAR_OPTION_NAME,
PRODUCT_EDITOR_FEEDBACK_CES_ACTION,
} from '../../constants';
import { PRODUCT_EDITOR_SHOW_FEEDBACK_BAR_OPTION_NAME } from '../../constants';
export const useFeedbackBar = () => {
const { updateOptions } = useDispatch( OPTIONS_STORE_NAME );
const { wasPreviouslyShown, isLoading: isCesModalOptionsLoading } =
useCustomerEffortScoreModal();
const { shouldShowFeedbackBar } = useSelect( ( select ) => {
const { getOption, hasFinishedResolution } =
select( OPTIONS_STORE_NAME );
const { shouldShowFeedbackBar } = useSelect(
( select ) => {
const { getOption, hasFinishedResolution } =
select( OPTIONS_STORE_NAME );
const showFeedbackBarOption = getOption(
PRODUCT_EDITOR_SHOW_FEEDBACK_BAR_OPTION_NAME
) as string;
const showFeedbackBarOption = getOption(
PRODUCT_EDITOR_SHOW_FEEDBACK_BAR_OPTION_NAME
) as string;
const resolving = ! hasFinishedResolution( 'getOption', [
PRODUCT_EDITOR_SHOW_FEEDBACK_BAR_OPTION_NAME,
] );
const resolving = ! hasFinishedResolution( 'getOption', [
PRODUCT_EDITOR_SHOW_FEEDBACK_BAR_OPTION_NAME,
] );
return {
shouldShowFeedbackBar:
! resolving &&
window.wcTracks?.isEnabled &&
! isCesModalOptionsLoading &&
! wasPreviouslyShown(
PRODUCT_EDITOR_FEEDBACK_CES_ACTION
) &&
showFeedbackBarOption === 'yes',
};
},
[ isCesModalOptionsLoading, wasPreviouslyShown ]
);
return {
shouldShowFeedbackBar:
! resolving &&
window.wcTracks?.isEnabled &&
showFeedbackBarOption === 'yes',
};
}, [] );
const showFeedbackBar = () => {
updateOptions( {
@ -67,11 +53,7 @@ export const useFeedbackBar = () => {
const maybeShowFeedbackBar = async () => {
const { showFeedbackBarOption } = await getOptions();
if (
window.wcTracks?.isEnabled &&
! wasPreviouslyShown( PRODUCT_EDITOR_FEEDBACK_CES_ACTION ) &&
showFeedbackBarOption !== 'no'
) {
if ( window.wcTracks?.isEnabled && showFeedbackBarOption !== 'no' ) {
showFeedbackBar();
}
};