From 9d4381a8fdf7ff953da0a6ef791e518ccb2701f9 Mon Sep 17 00:00:00 2001 From: David Dias Date: Wed, 28 Jun 2017 10:44:25 +0100 Subject: [PATCH] round 2 - go for ipfs in a chrome-extension --- app/browser/ipfs.js | 77 ---------------------------------------- js/constants/messages.js | 4 +-- js/stores/appStore.js | 2 -- 3 files changed, 1 insertion(+), 82 deletions(-) delete mode 100644 app/browser/ipfs.js diff --git a/app/browser/ipfs.js b/app/browser/ipfs.js deleted file mode 100644 index d229b72e56f..00000000000 --- a/app/browser/ipfs.js +++ /dev/null @@ -1,77 +0,0 @@ -/* IPFS node in electron's main process */ - -// TODO(diasdavid) - review electron's main process support https://github.com/ipfs/js-ipfs/issues/843 - -// const electron = require('electron') -// const ipc = electron.ipcMain -// const messages = require('../../js/constants/messages') -// const IPFS = require('ipfs') -// const os = require('os') -// const path = require('path') - -module.exports = {init} - -// Set to see communication between WebTorrent and torrent viewer tabs -const DEBUG_IPC = false -if (DEBUG_IPC) { - console.log('IPFS IPC debugging enabled') -} - -// IPFS node -// let node = null -// let channels = {} - -// Receive messages via the window process, ultimately from the UI in a process -function init (state, action) { - if (DEBUG_IPC) { - console.log('IPFS IPC init') - } - - return state - - /* - node = new IPFS({ - repo: path.join(os.homedir(), '/.brave-jsipfs') - }) - - node.on('ready', () => { - if (DEBUG_IPC) { - console.log('IPFS node is ready') - } - }) - - node.on('error', (err) => console.log('IPFS: ', err)) - - // access on the browser with remote.getGlobal('ipfs') - global.ipfs = node - */ - - /* TODO(diasdavid) consider enabling the browser tab to start and stop the node - ipc.on(messages.IPFS_MESSAGE, function (event, msg) { - if (DEBUG_IPC) { - console.log('IPFS: Received IPC: ' + JSON.stringify(msg)) - } - - channels[msg.clientKey] = e.sender - server.receive(msg) - }) - */ -} - -// Send messages from the browser process (here), thru the window process, to the -/* -function send (msg) { - if (DEBUG_IPC) console.log('Sending IPC: ' + JSON.stringify(msg)) - const channel = channels[msg.clientKey] - if (!channel) { - if (DEBUG_IPC) console.error('Ignoring unrecognized clientKey ' + msg.clientKey) - return - } - if (channel.isDestroyed()) { - if (DEBUG_IPC) console.log('Removing destroyed channel, clientKey ' + msg.clientKey) - delete channels[msg.clientKey] - return - } - channel.send(messages.IPFS_MESSAGE, msg) -} -*/ diff --git a/js/constants/messages.js b/js/constants/messages.js index aa5401ff1a1..b5eb7321de5 100644 --- a/js/constants/messages.js +++ b/js/constants/messages.js @@ -147,9 +147,7 @@ const messages = { // PDFJS LOAD_URL_REQUESTED: _, // Torrent - TORRENT_MESSAGE: _, - // IPFS - IPFS_MESSAGE: _ + TORRENT_MESSAGE: _ // DO NOT ADD TO THIS LIST - see above } diff --git a/js/stores/appStore.js b/js/stores/appStore.js index 7a8cb9ca74b..b2dae4c423e 100644 --- a/js/stores/appStore.js +++ b/js/stores/appStore.js @@ -428,8 +428,6 @@ const handleAppAction = (action) => { appState = filtering.init(appState, action, appStore) appState = basicAuth.init(appState, action, appStore) appState = webtorrent.init(appState, action, appStore) - // TODO(diasdavid) - init IPFS in the main process - appState = ipfs.init(appState, action, appStore) appState = profiles.init(appState, action, appStore) appState = require('../../app/browser/menu').init(appState, action, appStore) appState = require('../../app/sync').init(appState, action, appStore)