Fix incorrect data while loading in useInstalledPlugins.
This commit is contained in:
parent
f45e43b990
commit
79023a4a10
|
@ -25,8 +25,14 @@ export type UseInstalledPlugins = {
|
||||||
* The list of installed plugins will not include registered and recommended marketing channels.
|
* The list of installed plugins will not include registered and recommended marketing channels.
|
||||||
*/
|
*/
|
||||||
export const useInstalledPlugins = (): UseInstalledPlugins => {
|
export const useInstalledPlugins = (): UseInstalledPlugins => {
|
||||||
const { data: dataRegisteredChannels = [] } = useRegisteredChannels();
|
const {
|
||||||
const { data: dataRecommendedChannels = [] } = useRecommendedChannels();
|
loading: loadingRegisteredChannels,
|
||||||
|
data: dataRegisteredChannels = [],
|
||||||
|
} = useRegisteredChannels();
|
||||||
|
const {
|
||||||
|
loading: loadingRecommendedChannels,
|
||||||
|
data: dataRecommendedChannels = [],
|
||||||
|
} = useRecommendedChannels();
|
||||||
|
|
||||||
const { installedPlugins, activatingPlugins } = useSelect( ( select ) => {
|
const { installedPlugins, activatingPlugins } = useSelect( ( select ) => {
|
||||||
const { getInstalledPlugins, getActivatingPlugins } =
|
const { getInstalledPlugins, getActivatingPlugins } =
|
||||||
|
@ -38,6 +44,10 @@ export const useInstalledPlugins = (): UseInstalledPlugins => {
|
||||||
};
|
};
|
||||||
}, [] );
|
}, [] );
|
||||||
|
|
||||||
|
const { activateInstalledPlugin, loadInstalledPluginsAfterActivation } =
|
||||||
|
useDispatch( STORE_KEY );
|
||||||
|
|
||||||
|
const loading = loadingRegisteredChannels || loadingRecommendedChannels;
|
||||||
const installedPluginsWithoutChannels = chain( installedPlugins )
|
const installedPluginsWithoutChannels = chain( installedPlugins )
|
||||||
.differenceWith( dataRegisteredChannels, ( a, b ) => a.slug === b.slug )
|
.differenceWith( dataRegisteredChannels, ( a, b ) => a.slug === b.slug )
|
||||||
.differenceWith(
|
.differenceWith(
|
||||||
|
@ -46,11 +56,8 @@ export const useInstalledPlugins = (): UseInstalledPlugins => {
|
||||||
)
|
)
|
||||||
.value();
|
.value();
|
||||||
|
|
||||||
const { activateInstalledPlugin, loadInstalledPluginsAfterActivation } =
|
|
||||||
useDispatch( STORE_KEY );
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
installedPlugins: installedPluginsWithoutChannels,
|
installedPlugins: loading ? [] : installedPluginsWithoutChannels,
|
||||||
activatingPlugins,
|
activatingPlugins,
|
||||||
activateInstalledPlugin,
|
activateInstalledPlugin,
|
||||||
loadInstalledPluginsAfterActivation,
|
loadInstalledPluginsAfterActivation,
|
||||||
|
|
Loading…
Reference in New Issue