From 9310ecc31e14a8ea90013bb7abccfa07de9a9cb8 Mon Sep 17 00:00:00 2001 From: aniket-engg Date: Wed, 22 Dec 2021 20:46:53 +0530 Subject: [PATCH] plugin calls for methods --- apps/remix-ide/src/app.js | 20 +++++++++++++++++++- apps/remix-ide/src/app/tabs/compile-tab.js | 9 ++------- libs/remix-ui/renderer/src/lib/renderer.tsx | 8 ++++---- 3 files changed, 25 insertions(+), 12 deletions(-) diff --git a/apps/remix-ide/src/app.js b/apps/remix-ide/src/app.js index e4c1217a12..117a11fc5a 100644 --- a/apps/remix-ide/src/app.js +++ b/apps/remix-ide/src/app.js @@ -55,7 +55,7 @@ const profile = { name: 'app', displayName: 'App', description: 'Application', - methods: [] + methods: ['getAppParameter', 'setAppParameter'] } class AppComponent extends Plugin { @@ -63,6 +63,7 @@ class AppComponent extends Plugin { super(profile) const self = this self.appManager = new RemixAppManager({}) + self.queryParams = new QueryParams() self._components = {} self.registry = registry // setup storage @@ -86,6 +87,22 @@ class AppComponent extends Plugin { migrateFileSystem(self._components.filesProviders.browser) } + getAppParameter (name) { + // first look in the URL params then in the local storage + const self = this + const params = self.queryParams.get() + const config = registry.get('config').api + const param = params[name] ? params[name] : config.get(name) + if (param === 'true') return true + if (param === 'false') return false + return param + } + + setAppParameter (name, value) { + const config = registry.get('config').api + config.set(name, value) + } + async run () { const self = this // APP_MANAGER @@ -168,6 +185,7 @@ class AppComponent extends Plugin { const contextualListener = new ContextualListener({ editor }) self.engine.register([ + this, blockchain, contentImport, self.themeModule, diff --git a/apps/remix-ide/src/app/tabs/compile-tab.js b/apps/remix-ide/src/app/tabs/compile-tab.js index a640285566..bd2a9ca0cd 100644 --- a/apps/remix-ide/src/app/tabs/compile-tab.js +++ b/apps/remix-ide/src/app/tabs/compile-tab.js @@ -145,16 +145,11 @@ class CompileTab extends CompilerApiMixin(ViewPlugin) { // implements ICompilerA } getAppParameter (name) { - // first look in the URL params then in the local storage - const params = this.queryParams.get() - const param = params[name] ? params[name] : this.config.get(name) - if (param === 'true') return true - if (param === 'false') return false - return param + this.call('app', 'getAppParameter', name) } setAppParameter (name, value) { - this.config.set(name, value) + this.call('app', 'setAppParameter', name, value) } } diff --git a/libs/remix-ui/renderer/src/lib/renderer.tsx b/libs/remix-ui/renderer/src/lib/renderer.tsx index 41f345cf3d..273be5e0b0 100644 --- a/libs/remix-ui/renderer/src/lib/renderer.tsx +++ b/libs/remix-ui/renderer/src/lib/renderer.tsx @@ -69,7 +69,7 @@ export const Renderer = ({ message, opt = {}, plugin }: RendererProps) => { } const addAnnotation = (file, error) => { - if (file === plugin.getAppParameter('currentFile')) { + if (file === plugin.call('app', 'getAppParameter', 'currentFile')) { plugin.call('editor', 'addAnnotation', error, file) } } @@ -87,10 +87,10 @@ export const Renderer = ({ message, opt = {}, plugin }: RendererProps) => { } const _errorClick = async (errFile, errLine, errCol) => { - if (errFile !== plugin.getAppParameter('currentFile')) { + if (errFile !== plugin.call('app', 'getAppParameter', 'currentFile')) { // TODO: refactor with this._components.contextView.jumpTo - if (await plugin.fileExists(errFile)) { - plugin.open(errFile) + if (await plugin.call('fileManager', 'exists', errFile)) { + plugin.call('fileManager', 'open', errFile) plugin.call('editor', 'gotoLine', errLine, errCol) } } else {