Skip to content

Commit

Permalink
Drop unneeded currentUserEmail
Browse files Browse the repository at this point in the history
  • Loading branch information
alshakero committed Jun 20, 2024
1 parent b15c912 commit 0ec332a
Show file tree
Hide file tree
Showing 6 changed files with 5 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ function AdminHelpCenterContent() {
locale={ window.helpCenterData.locale }
sectionName="wp-admin"
currentUserId={ window.helpCenterData.current_user_id }
currentUserEmail={ window.helpCenterData.userEmail }
isBusinessOrEcomPlanUser={ window.helpCenterData.is_business_or_ecommerce_plan_user }
selectedSiteId={ window.helpCenterData.current }
hasPurchases={ false }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ function HelpCenterContent() {
locale={ window.helpCenterData.locale }
sectionName="gutenberg-editor"
currentUserId={ window.helpCenterData.current_user_id }
currentUserEmail={ window.helpCenterData.userEmail }
isBusinessOrEcomPlanUser={ window.helpCenterData.is_business_or_ecommerce_plan_user }
selectedSiteId={ window.helpCenterData.current }
hasPurchases={ false }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { useLocale } from '@automattic/i18n-utils';
import { useDispatch, useSelect } from '@wordpress/data';
import AsyncLoad from 'calypso/components/async-load';
import { useSelector } from 'calypso/state';
import { getCurrentUserEmail, getCurrentUserId } from 'calypso/state/current-user/selectors';
import { getCurrentUserId } from 'calypso/state/current-user/selectors';
import { getUserPurchases } from 'calypso/state/purchases/selectors';
import getPrimarySiteId from 'calypso/state/selectors/get-primary-site-id';
import hasCancelableUserPurchases from 'calypso/state/selectors/has-cancelable-user-purchases';
Expand All @@ -22,7 +22,6 @@ const AsyncHelpCenter = () => {
const locale = useLocale();
const sectionName = useSelector( getSection );
const currentUserId = useSelector( getCurrentUserId );
const currentUserEmail = useSelector( getCurrentUserEmail );
const selectedSiteId = useSelector( getSelectedSiteId );
const userPurchases = useSelector( getUserPurchases );
const hasPurchases = useSelector( hasCancelableUserPurchases );
Expand Down Expand Up @@ -53,7 +52,6 @@ const AsyncHelpCenter = () => {
locale={ locale }
sectionName={ sectionName }
currentUserId={ currentUserId }
currentUserEmail={ currentUserEmail }
selectedSiteId={ selectedSiteId }
userPurchases={ userPurchases }
hasPurchases={ hasPurchases }
Expand Down
11 changes: 4 additions & 7 deletions packages/help-center/src/components/help-center-contact-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,7 @@ type HelpCenterContactFormProps = {

export const HelpCenterContactForm = ( props: HelpCenterContactFormProps ) => {
const { search } = useLocation();
const helpCenterContext = useHelpCenterContext();
const sectionName = helpCenterContext.sectionName;
const { sectionName, currentUserId } = useHelpCenterContext();
const params = new URLSearchParams( search );
const mode = params.get( 'mode' ) as Mode;
const { onSubmit } = props;
Expand All @@ -105,11 +104,9 @@ export const HelpCenterContactForm = ( props: HelpCenterContactFormProps ) => {
const locale = useLocale();
const { isPending: submittingTicket, mutateAsync: submitTicket } = useSubmitTicketMutation();
const { isPending: submittingTopic, mutateAsync: submitTopic } = useSubmitForumsMutation();
const userId = helpCenterContext?.currentUserId;
const { data: userSites } = useUserSites( userId );
const { data: userSites } = useUserSites( currentUserId );
const userWithNoSites = userSites?.sites.length === 0;
const queryClient = useQueryClient();
const email = helpCenterContext.currentUserEmail;
const [ sitePickerChoice, setSitePickerChoice ] = useState< 'CURRENT_SITE' | 'OTHER_SITE' >(
'CURRENT_SITE'
);
Expand Down Expand Up @@ -156,7 +153,7 @@ export const HelpCenterContactForm = ( props: HelpCenterContactFormProps ) => {

let ownershipResult: AnalysisReport = useSiteAnalysis(
// pass user email as query cache key
userId,
currentUserId,
userDeclaredSiteUrl,
sitePickerChoice === 'OTHER_SITE'
);
Expand Down Expand Up @@ -393,7 +390,7 @@ export const HelpCenterContactForm = ( props: HelpCenterContactFormProps ) => {
// wait 30 seconds until support-history endpoint actually updates
// yup, it takes that long (tried 5, and 10)
queryClient.invalidateQueries( {
queryKey: [ 'help-support-history', 'ticket', email ],
queryKey: [ 'help-support-history', 'ticket', currentUserId ],
} );
}, 30000 );
} )
Expand Down
3 changes: 0 additions & 3 deletions packages/help-center/src/components/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,6 @@ declare module 'calypso/state/selectors/has-cancelable-user-purchases' {
export default hasCancelableUserPurchases;
}

declare module 'calypso/state/current-user/selectors' {
export const getCurrentUserEmail: ( state: unknown ) => string;
}
declare module 'calypso/state/current-user/selectors' {
export const getCurrentUserId: ( state: unknown ) => string;
}
Expand Down
2 changes: 0 additions & 2 deletions packages/help-center/src/contexts/HelpCenterContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ export type HelpCenterRequiredInformation = {
locale: string;
sectionName: string;
currentUserId: number;
currentUserEmail: string;
selectedSiteId: number;
hasPurchases: boolean;
primarySiteId: number;
Expand All @@ -20,7 +19,6 @@ const HelpCenterRequiredContext = React.createContext< HelpCenterRequiredInforma
locale: '',
sectionName: '',
currentUserId: 0,
currentUserEmail: '',
selectedSiteId: 0,
hasPurchases: false,
primarySiteId: 0,
Expand Down

0 comments on commit 0ec332a

Please sign in to comment.