mirror of
https://github.com/wassname/talk.git
synced 2026-06-29 18:11:05 +08:00
Only use plugins_config in redux
This commit is contained in:
@@ -30,6 +30,7 @@ class Slot extends React.Component {
|
||||
className,
|
||||
`talk-slot-${kebabCase(fill)}`
|
||||
)}
|
||||
data-slot-name={fill}
|
||||
>
|
||||
{children}
|
||||
</Component>
|
||||
|
||||
+10
-2
@@ -66,8 +66,16 @@ function initExternalConfig({ store, pym, inIframe }) {
|
||||
}
|
||||
return new Promise(resolve => {
|
||||
pym.sendMessage('getConfig');
|
||||
pym.onMessage('config', config => {
|
||||
store.dispatch(mergeConfig(JSON.parse(config)));
|
||||
pym.onMessage('config', rawConfig => {
|
||||
const config = JSON.parse(rawConfig);
|
||||
if (config.plugin_config) {
|
||||
console.warn(
|
||||
'Deprecation Warning: `config.plugin_config` will be phased out soon, please replace `config.plugin_config with `config.plugins_config`'
|
||||
);
|
||||
config.plugins_config = config.plugin_config;
|
||||
delete config.plugin_config;
|
||||
}
|
||||
store.dispatch(mergeConfig(config));
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -68,47 +68,14 @@ function addMetaDataToSlotComponents(plugins) {
|
||||
});
|
||||
}
|
||||
|
||||
// @Deprecated
|
||||
const showPluginConfigDeprecationWarningOnce = (() => {
|
||||
let shown = false;
|
||||
return () => {
|
||||
if (!shown) {
|
||||
shown = true;
|
||||
console.warn(
|
||||
`deprecation warning: config.plugin_config will be phased out soon, please replace calls from config.plugin_config to config.plugins_config`
|
||||
);
|
||||
}
|
||||
};
|
||||
})();
|
||||
|
||||
/**
|
||||
* getSlotComponentProps calculate the props we would pass to the slot component.
|
||||
* query datas are only passed to the component if it is defined in `component.fragments`.
|
||||
*/
|
||||
function getSlotComponentProps(component, reduxState, props, queryData) {
|
||||
// @Deprecated
|
||||
const pluginsConfig =
|
||||
get(reduxState, 'config.plugins_config') ||
|
||||
get(reduxState, 'config.plugin_config') ||
|
||||
emptyConfig;
|
||||
|
||||
if (
|
||||
process.env.NODE_ENV !== 'production' &&
|
||||
!!get(reduxState, 'config.plugin_config')
|
||||
) {
|
||||
showPluginConfigDeprecationWarningOnce();
|
||||
}
|
||||
|
||||
console.log('slot plugins_config', get(reduxState, 'config.plugins_config'));
|
||||
|
||||
const debugProps = pluginsConfig.debug
|
||||
? {
|
||||
'data-slot-name': props.fill,
|
||||
}
|
||||
: {};
|
||||
const pluginsConfig = get(reduxState, 'config.plugins_config') || emptyConfig;
|
||||
return {
|
||||
...props,
|
||||
...debugProps,
|
||||
config: pluginsConfig,
|
||||
...(component.fragments
|
||||
? pick(queryData, Object.keys(component.fragments))
|
||||
@@ -159,9 +126,7 @@ class PluginsService {
|
||||
*/
|
||||
getSlotElements(slot, reduxState, props = {}, options = {}) {
|
||||
const pluginsConfig =
|
||||
get(reduxState, 'config.plugins_config') ||
|
||||
get(reduxState, 'config.plugin_config') ||
|
||||
emptyConfig;
|
||||
get(reduxState, 'config.plugins_config') || emptyConfig;
|
||||
const { size = 0 } = options;
|
||||
const { queryData, rest } = splitProps(props);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user