bug fixes

master
Enrico Fasoli 2019-03-09 16:29:00 +01:00
parent e9903eac00
commit 0c6d9a3a88
No known key found for this signature in database
GPG Key ID: 1238873C5F27DB4D
5 changed files with 12 additions and 22 deletions

View File

@ -60,7 +60,7 @@ export default class PostForm extends Component {
<Button as={Link} to={shortenAddress(address)}>
<Icon name="chevron left"/> Board
</Button>
<Button type='submit' onClick={() => onSave({ title, content })}>
<Button type='submit' onClick={() => onSave({ title, text: content })}>
<Icon name="save"/> Submit
</Button>
</Form>

View File

@ -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,

View File

@ -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' })

View File

@ -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'

View File

@ -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
}