Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Themes: Fix try&customize for themes on AT sites #11621

Merged
merged 1 commit into from
Feb 28, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 13 additions & 6 deletions client/state/themes/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -350,9 +350,7 @@ export function requestActiveTheme( siteId ) {
export function activate( themeId, siteId, source = 'unknown', purchased = false ) {
return ( dispatch, getState ) => {
if ( isJetpackSite( getState(), siteId ) && ! getTheme( getState(), siteId, themeId ) ) {
// AT sites do not use the -wpcom suffix
const siteIsAT = isSiteAutomatedTransfer( getState(), siteId );
const installId = siteIsAT ? themeId : themeId + '-wpcom';
const installId = suffixThemeIdForInstall( getState(), siteId, themeId );
// If theme is already installed, installation will silently fail,
// and it will just be activated.
return dispatch( installAndActivateTheme( installId, siteId, source, purchased ) );
Expand Down Expand Up @@ -504,9 +502,10 @@ export function clearActivated( siteId ) {
export function tryAndCustomize( themeId, siteId ) {
return ( dispatch, getState ) => {
if ( isJetpackSite( getState(), siteId ) && ! getTheme( getState(), siteId, themeId ) ) {
// Suffix themeId here with `-wpcom`. If the suffixed theme is already installed,
// installation will silently fail, and we just switch to the customizer.
return dispatch( installAndTryAndCustomizeTheme( themeId + '-wpcom', siteId ) );
const installId = suffixThemeIdForInstall( getState(), siteId, themeId );
// If theme is already installed, installation will silently fail,
// and we just switch to the customizer.
return dispatch( installAndTryAndCustomizeTheme( installId, siteId ) );
}

return dispatch( tryAndCustomizeTheme( themeId, siteId ) );
Expand Down Expand Up @@ -826,3 +825,11 @@ export function hideThemePreview() {
themeId: null
};
}

function suffixThemeIdForInstall( state, siteId, themeId ) {
// AT sites do not use the -wpcom suffix
if ( isSiteAutomatedTransfer( state, siteId ) ) {
return themeId;
}
return themeId + '-wpcom';
}