diff --git a/libs/remix-ui/plugin-manager/src/lib/components/ActivePluginCard.tsx b/libs/remix-ui/plugin-manager/src/lib/components/ActivePluginCard.tsx index 28f2b9b973..f57d3a9085 100644 --- a/libs/remix-ui/plugin-manager/src/lib/components/ActivePluginCard.tsx +++ b/libs/remix-ui/plugin-manager/src/lib/components/ActivePluginCard.tsx @@ -49,11 +49,9 @@ function ActivePluginCard ({ deactivatePlugin(profile.name) const actives: Profile[] = JSON.parse(localStorage.getItem('newActivePlugins')) if (actives && actives.length) { - // const newList = actives.filter(active => active.name !== profile.name) const newList = _.remove(actives, active => active.name !== profile.name) - console.log('removed using lodash and this is the result', newList) + // console.log('removed using lodash and this is the result', newList) localStorage.setItem('newActivePlugins', JSON.stringify(newList)) - setActivePlugins([]) setActivePlugins(newList) } } } diff --git a/libs/remix-ui/plugin-manager/src/lib/components/InactivePluginCardContainer.tsx b/libs/remix-ui/plugin-manager/src/lib/components/InactivePluginCardContainer.tsx index 5f0f854521..ec834de8de 100644 --- a/libs/remix-ui/plugin-manager/src/lib/components/InactivePluginCardContainer.tsx +++ b/libs/remix-ui/plugin-manager/src/lib/components/InactivePluginCardContainer.tsx @@ -40,7 +40,6 @@ function InactivePluginCardContainer ({ pluginComponent, setInactiveProfiles, in return active.name === t.name }) }) - console.log(filtered) setInactiveProfiles(filtered) } }, [pluginComponent, pluginComponent.inactivePlugins, setInactiveProfiles]) diff --git a/libs/remix-ui/plugin-manager/src/lib/components/LocalPluginForm.tsx b/libs/remix-ui/plugin-manager/src/lib/components/LocalPluginForm.tsx index ef8bb29d3c..8f294ea163 100644 --- a/libs/remix-ui/plugin-manager/src/lib/components/LocalPluginForm.tsx +++ b/libs/remix-ui/plugin-manager/src/lib/components/LocalPluginForm.tsx @@ -4,7 +4,7 @@ import { ModalDialog } from '@remix-ui/modal-dialog' import { Toaster } from '@remix-ui/toaster' import { IframePlugin, WebsocketPlugin } from '@remixproject/engine-web' import { FormStateProps, PluginManagerComponent } from '../../types' -import { localPluginReducerActionType, localPluginToastReducer } from '../../pluginManagerReducer' +import { localPluginReducerActionType, localPluginToastReducer } from '../reducers/pluginManagerReducer' interface LocalPluginFormProps { changeHandler: (propertyName: string, value: any) => void diff --git a/libs/remix-ui/plugin-manager/src/pluginManagerReducer.ts b/libs/remix-ui/plugin-manager/src/lib/reducers/pluginManagerReducer.ts similarity index 59% rename from libs/remix-ui/plugin-manager/src/pluginManagerReducer.ts rename to libs/remix-ui/plugin-manager/src/lib/reducers/pluginManagerReducer.ts index 014b140c6e..c7ddeffdb7 100644 --- a/libs/remix-ui/plugin-manager/src/pluginManagerReducer.ts +++ b/libs/remix-ui/plugin-manager/src/lib/reducers/pluginManagerReducer.ts @@ -8,5 +8,14 @@ export function localPluginToastReducer (currentState: string, toastAction: loca switch (toastAction.type) { case 'show': return `Cannot create Plugin : ${toastAction.payload!}` + default: + return currentState } } + +export interface activePluginActionType { + type: 'load' | 'refresh' +} +export function loadActivePluginsReducer (activated: string[], action: activePluginActionType) { + +} diff --git a/libs/remix-ui/plugin-manager/src/lib/remix-ui-plugin-manager.tsx b/libs/remix-ui/plugin-manager/src/lib/remix-ui-plugin-manager.tsx index e33c237255..53e39b48f2 100644 --- a/libs/remix-ui/plugin-manager/src/lib/remix-ui-plugin-manager.tsx +++ b/libs/remix-ui/plugin-manager/src/lib/remix-ui-plugin-manager.tsx @@ -1,5 +1,5 @@ import { Profile } from '@remixproject/plugin-utils' -import React, { useState } from 'react' +import React, { useEffect, useState } from 'react' import { RemixUiPluginManagerProps } from '../types' import ActivePluginCardContainer from './components/ActivePluginCardContainer' import InactivePluginCardContainer from './components/InactivePluginCardContainer' @@ -9,6 +9,8 @@ import './remix-ui-plugin-manager.css' export const RemixUiPluginManager = ({ pluginComponent }: RemixUiPluginManagerProps) => { const [activeProfiles, setActiveProfiles] = useState(pluginComponent.activePlugins) const [inactiveProfiles, setinactiveProfiles] = useState(pluginComponent.inactivePlugins) + const [activated] = useState(pluginComponent.activeProfiles) + if (JSON.parse(localStorage.getItem('newActivePlugins')) === null) { localStorage.setItem('newActivePlugins', '[]') } @@ -18,7 +20,26 @@ export const RemixUiPluginManager = ({ pluginComponent }: RemixUiPluginManagerPr if (JSON.parse(localStorage.getItem('activatedPluginNames'))) { localStorage.setItem('activatedPluginNames', '[]') } + console.log('activated profile names :', activated) + useEffect(() => { + console.log('first time into use effect the activated state is', activated) + const checkSolidity = async () => { + const savedActives: Profile[] = JSON.parse(localStorage.getItem('newActivePlugins')) + if (activated.includes('solidity') && activated.includes('solidity-logic')) { + if (savedActives && savedActives.length >= 0) { + if (!savedActives.find(active => active.name === 'solidity') && !savedActives.find(active => active.name === 'solidity-logic')) { + const solidity = await pluginComponent.appManager.getProfile('solidity') + const logic = await pluginComponent.appManager.getProfile('solidity-logic') + savedActives.push(solidity, logic) + } + } + } + console.log('Use effect called, activated state is', activated) + } + checkSolidity() + console.log('activated state right at useEffect exit', activated) + }, [activated, pluginComponent.appManager]) return (