From f99d67306c17001e5806c8229e999bd29e50911f Mon Sep 17 00:00:00 2001 From: filip mertens Date: Wed, 29 Sep 2021 10:56:55 +0200 Subject: [PATCH] migrating --- apps/remix-ide/src/assets/js/init.js | 30 +++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/apps/remix-ide/src/assets/js/init.js b/apps/remix-ide/src/assets/js/init.js index f3b9acb1d7..d39198c31a 100644 --- a/apps/remix-ide/src/assets/js/init.js +++ b/apps/remix-ide/src/assets/js/init.js @@ -96,11 +96,35 @@ window.onload = () => { } } } - window.remixFileSystemCallback = new RemixFileSystem() - window.remixFileSystemCallback.init('RemixFileSystem').then(() => { - window.remixFileSystem = window.remixFileSystemCallback.promises + + function loadApp(){ const app = document.createElement('script') app.setAttribute('src', versions[versionToLoad]) document.body.appendChild(app) + } + + function migrateFiles(){ + BrowserFS.install(window) + BrowserFS.configure({ + fs: "LocalStorage" + }, function(e) { + if (e) console.log(e) + let browserFS = require('fs') + console.log(browserFS) + }) + } + + window.remixFileSystemCallback = new RemixFileSystem() + window.remixFileSystemCallback.init('RemixFileSystem').then(() => { + window.remixFileSystem = window.remixFileSystemCallback.promises + // check if .workspaces is present in indexeddb + window.remixFileSystem.stat('.workspaces2').then((dir) => { + if(dir.isDirectory()) loadApp() + }).catch(()=>{ + // no indexeddb workspaces + console.log("loading localstorage FS") + migrateFiles(); + }); + }) }