From 07548dd7621fd6a45ff5f87794d0efc9f64968db Mon Sep 17 00:00:00 2001 From: ioedeveloper Date: Tue, 3 Aug 2021 16:35:04 +0100 Subject: [PATCH] Fixed Github import from homepage --- apps/remix-ide/src/app.js | 2 +- apps/remix-ide/src/app/ui/landing-page/landing-page.js | 8 ++++---- .../remix-core-plugin/src/lib/compiler-content-imports.ts | 7 ++++++- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/apps/remix-ide/src/app.js b/apps/remix-ide/src/app.js index d2397b7ac9..67ede9b1bd 100644 --- a/apps/remix-ide/src/app.js +++ b/apps/remix-ide/src/app.js @@ -338,7 +338,7 @@ Please make a backup of your contracts and start using http://remix.ethereum.org const hiddenPanel = new HiddenPanel() const pluginManagerComponent = new PluginManagerComponent(appManager, engine) const filePanel = new FilePanel(appManager) - const landingPage = new LandingPage(appManager, menuicons, fileManager, filePanel) + const landingPage = new LandingPage(appManager, menuicons, fileManager, filePanel, contentImport) const settings = new SettingsTab( registry.get('config').api, editor, diff --git a/apps/remix-ide/src/app/ui/landing-page/landing-page.js b/apps/remix-ide/src/app/ui/landing-page/landing-page.js index 7085a04649..60d762472f 100644 --- a/apps/remix-ide/src/app/ui/landing-page/landing-page.js +++ b/apps/remix-ide/src/app/ui/landing-page/landing-page.js @@ -1,7 +1,6 @@ import * as packageJson from '../../../../../../package.json' import { ViewPlugin } from '@remixproject/engine-web' import { migrateToWorkspace } from '../../../migrateFileSystem' -import { CompilerImports } from '@remix-project/core-plugin' import JSZip from 'jszip' const yo = require('yo-yo') @@ -119,11 +118,12 @@ const profile = { } export class LandingPage extends ViewPlugin { - constructor (appManager, verticalIcons, fileManager, filePanel) { + constructor (appManager, verticalIcons, fileManager, filePanel, contentImport) { super(profile) this.profile = profile this.fileManager = fileManager this.filePanel = filePanel + this.contentImport = contentImport this.appManager = appManager this.verticalIcons = verticalIcons this.gistHandler = new GistHandler() @@ -240,7 +240,7 @@ export class LandingPage extends ViewPlugin { render () { const load = (service, item, examples, info) => { - const compilerImport = new CompilerImports() + const contentImport = this.contentImport const fileProviders = globalRegistry.get('fileproviders').api const msg = yo`
@@ -252,7 +252,7 @@ export class LandingPage extends ViewPlugin { const title = `Import from ${service}` modalDialogCustom.prompt(title, msg, null, (target) => { if (target !== '') { - compilerImport.import( + contentImport.import( target, (loadingMsg) => { tooltip(loadingMsg) }, (error, content, cleanUrl, type, url) => { diff --git a/libs/remix-core-plugin/src/lib/compiler-content-imports.ts b/libs/remix-core-plugin/src/lib/compiler-content-imports.ts index ea4eae6958..93d8b61e5c 100644 --- a/libs/remix-core-plugin/src/lib/compiler-content-imports.ts +++ b/libs/remix-core-plugin/src/lib/compiler-content-imports.ts @@ -22,7 +22,12 @@ export class CompilerImports extends Plugin { async setToken () { const protocol = typeof window !== 'undefined' && window.location.protocol - const token = await this.call('settings', 'get', 'settings/gist-access-token') + let token + try { + token = await this.call('settings', 'get', 'settings/gist-access-token') + } catch (error) { + console.log(error) + } this.urlResolver.setGistToken(token, protocol) }