Skip to content

Commit

Permalink
refactor: Rename plugin config to setup info to improve clarity for p…
Browse files Browse the repository at this point in the history
…lugin developers
  • Loading branch information
tjtanjin committed Oct 26, 2024
1 parent be11b47 commit bde9c31
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions src/hooks/internal/usePluginsInternal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,36 +14,36 @@ export const usePluginsInternal = (plugins: Array<Plugin> | undefined,
const { updateSettings } = useSettingsInternal();
const { updateStyles } = useStylesInternal();

// initializes plugins
const configs = plugins?.map((pluginHook) => pluginHook());
// initializes plugins and retrieves info for setup
const setUpInfo = plugins?.map((pluginHook) => pluginHook());

useEffect(() => {
// applies plugin themes, settings and styles if specified
configs?.forEach((pluginConfig) => {
if (pluginConfig.themes) {
if (Array.isArray(pluginConfig.themes)) {
setUpInfo?.forEach((setUpInfo) => {
if (setUpInfo.themes) {
if (Array.isArray(setUpInfo.themes)) {
setFinalThemes(prev => {
if (Array.isArray(prev)) {
return [...prev, ...pluginConfig.themes as Array<Theme>];
return [...prev, ...setUpInfo.themes as Array<Theme>];
} else {
return [prev, ...pluginConfig.themes as Array<Theme>];
return [prev, ...setUpInfo.themes as Array<Theme>];
}
});
} else {
setFinalThemes(prev => {
if (Array.isArray(prev)) {
return [...prev, pluginConfig.themes as Theme];
return [...prev, setUpInfo.themes as Theme];
} else {
return [prev, pluginConfig.themes as Theme];
return [prev, setUpInfo.themes as Theme];
}
});
}
}
if (pluginConfig?.settings) {
updateSettings(pluginConfig.settings);
if (setUpInfo?.settings) {
updateSettings(setUpInfo.settings);
}
if (pluginConfig?.styles) {
updateStyles(pluginConfig.styles);
if (setUpInfo?.styles) {
updateStyles(setUpInfo.styles);
}
});
}, [plugins])
Expand Down

0 comments on commit bde9c31

Please sign in to comment.