diff --git a/src/components/PostForm.js b/src/components/PostForm.js index 0d18d6d..730ee37 100644 --- a/src/components/PostForm.js +++ b/src/components/PostForm.js @@ -60,7 +60,7 @@ export default class PostForm extends Component { - diff --git a/src/orbitdb/index.js b/src/orbitdb/index.js index c2afaee..7d8a1a2 100644 --- a/src/orbitdb/index.js +++ b/src/orbitdb/index.js @@ -17,20 +17,11 @@ export async function start() { window.ipfs = new IPFS({ repo: 'ipfs-v6-boards-v0', EXPERIMENTAL: { - pubsub: true - }, - config: { - Addresses: { - Swarm: [ - '/dns4/ws-star.discovery.libp2p.io/tcp/443/wss/p2p-websocket-star', - '/dns4/ws-star-signal-1.servep2p.com/tcp/443/wss/p2p-websocket-star', - '/dns4/ws-star-signal-2.servep2p.com/tcp/443/wss/p2p-websocket-star' - ] - } + pubsub: true } }); - await new Promise(fullfill => { - window.ipfs.on('ready', () => fullfill()) + await new Promise(resolve => { + window.ipfs.on('ready', () => resolve()) }) } if (!window.orbitDb) { @@ -40,6 +31,7 @@ export async function start() { } export async function open(address, metadata) { + if (window.dbs && window.dbs[address]) return window.dbs[address] await start() const options = { type: BoardStore.type, diff --git a/src/sagas/boards.js b/src/sagas/boards.js index df10422..1ad7397 100644 --- a/src/sagas/boards.js +++ b/src/sagas/boards.js @@ -1,4 +1,4 @@ -import { put, call, fork, take, apply } from 'redux-saga/effects' +import { put, call, fork, take } from 'redux-saga/effects' import { eventChannel } from 'redux-saga' import { push } from 'react-router-redux' import { open, connectDb } from '../orbitdb' @@ -31,7 +31,7 @@ export function* closeBoard({ address }){ export function* updateBoardMetadata({ address, metadata }){ const db = window.dbs[address] if (db) { - yield apply(db, db.updateMetadata, [metadata]) + yield call([db, db.updateMetadata], [metadata]) yield goToBoard({ board: { address } }); } else { yield put({ type: 'ERROR', error: address + ' not found' }) diff --git a/src/sagas/index.js b/src/sagas/index.js index 596e128..5c0766a 100644 --- a/src/sagas/index.js +++ b/src/sagas/index.js @@ -9,7 +9,6 @@ import { UPDATE_BOARD_METADATA } from '../actions/actionTypes' import { openBoard, updateBoard, goToBoard, updateBoardMetadata, closeBoard } from './boards' -import { openBoard as openBoardAction } from '../actions/board' import { addPost } from './posts' import { openPreviousBoards, saveSaga } from './persistence' diff --git a/src/sagas/posts.js b/src/sagas/posts.js index 7ba6be1..60d9f85 100644 --- a/src/sagas/posts.js +++ b/src/sagas/posts.js @@ -1,19 +1,18 @@ -import { apply, call } from 'redux-saga/effects' -import { ipfsPut } from '../utils/ipfs' +import { call } from 'redux-saga/effects' import { goToBoard } from './boards'; export function* addPost({ address, post }) { const db = window.dbs[address] const { title, text } = post - yield apply(db, db.addPost, { title, text }) - yield goToBoard({ board: { address } }); + yield call([db, db.addPost], { title, text }) + yield goToBoard({ board: { address, redirect: true } }); // TODO: goto post } export function* editPost({ address, postId, post }) { const db = window.dbs[address] const { title, text } = post - yield apply(db, db.updatePost, [postId, { title, text }]) - yield goToBoard({ board: { address } }); + yield call([db, db.updatePost], postId, { title, text }) + yield goToBoard({ board: { address, redirect: true } }); // TODO: goto post } \ No newline at end of file