From eb40d2c058e4d21fbf780e7254f85c50abb3b319 Mon Sep 17 00:00:00 2001 From: zeppi Date: Mon, 16 Nov 2020 17:35:25 -0500 Subject: [PATCH] persist publish language fix publish language default --- dist/bundle.es.js | 17 ++++++++++------- src/redux/reducers/publish.js | 1 + src/redux/selectors/publish.js | 13 ++++++++----- 3 files changed, 19 insertions(+), 12 deletions(-) diff --git a/dist/bundle.es.js b/dist/bundle.es.js index 7247e28..5e682c7 100644 --- a/dist/bundle.es.js +++ b/dist/bundle.es.js @@ -4163,16 +4163,18 @@ const selectIsStillEditing = reselect.createSelector(selectState$3, publishState return currentName === editName; }); -const selectPublishFormValues = reselect.createSelector(selectState$3, selectIsStillEditing, (state, isStillEditing) => { - const { pendingPublish, language, languages } = state, - formValues = _objectWithoutProperties$2(state, ['pendingPublish', 'language', 'languages']); +const selectPublishFormValues = reselect.createSelector(selectState$3, state => state.settings, selectIsStillEditing, (publishState, settingsState, isStillEditing) => { + const { pendingPublish, language } = publishState, + formValues = _objectWithoutProperties$2(publishState, ['pendingPublish', 'language']); + const { clientSettings } = settingsState; + const { language: languageSet } = clientSettings; let actualLanguage; // Sets default if editing a claim with a set language - if (!language && isStillEditing && languages && languages[0]) { - actualLanguage = languages[0]; + if (!language && isStillEditing && languageSet) { + actualLanguage = languageSet; } else { - actualLanguage = language || 'en'; + actualLanguage = language || languageSet || 'en'; } return _extends$6({}, formValues, { language: actualLanguage }); }); @@ -5674,7 +5676,8 @@ const publishReducer = handleActions({ [CLEAR_PUBLISH]: state => _extends$c({}, defaultState$4, { channel: state.channel, bid: state.bid, - optimize: state.optimize + optimize: state.optimize, + language: state.language }), [PUBLISH_START]: state => _extends$c({}, state, { publishing: true, diff --git a/src/redux/reducers/publish.js b/src/redux/reducers/publish.js index c6ffb10..e33b57d 100644 --- a/src/redux/reducers/publish.js +++ b/src/redux/reducers/publish.js @@ -86,6 +86,7 @@ export const publishReducer = handleActions( channel: state.channel, bid: state.bid, optimize: state.optimize, + language: state.language, }), [ACTIONS.PUBLISH_START]: (state: PublishState): PublishState => ({ ...state, diff --git a/src/redux/selectors/publish.js b/src/redux/selectors/publish.js index 10ed95b..9ed5c92 100644 --- a/src/redux/selectors/publish.js +++ b/src/redux/selectors/publish.js @@ -40,16 +40,19 @@ export const selectIsStillEditing = createSelector( export const selectPublishFormValues = createSelector( selectState, + state => state.settings, selectIsStillEditing, - (state, isStillEditing) => { - const { pendingPublish, language, languages, ...formValues } = state; + (publishState, settingsState, isStillEditing) => { + const { pendingPublish, language, ...formValues } = publishState; + const { clientSettings } = settingsState; + const { language: languageSet } = clientSettings; let actualLanguage; // Sets default if editing a claim with a set language - if (!language && isStillEditing && languages && languages[0]) { - actualLanguage = languages[0]; + if (!language && isStillEditing && languageSet) { + actualLanguage = languageSet; } else { - actualLanguage = language || 'en'; + actualLanguage = language || languageSet || 'en'; } return { ...formValues, language: actualLanguage }; }