mirror of
https://github.com/fazo96/ipfs-boards
synced 2025-01-09 12:19:49 +01:00
bug fixes
This commit is contained in:
parent
e9903eac00
commit
0c6d9a3a88
@ -60,7 +60,7 @@ export default class PostForm extends Component {
|
|||||||
<Button as={Link} to={shortenAddress(address)}>
|
<Button as={Link} to={shortenAddress(address)}>
|
||||||
<Icon name="chevron left"/> Board
|
<Icon name="chevron left"/> Board
|
||||||
</Button>
|
</Button>
|
||||||
<Button type='submit' onClick={() => onSave({ title, content })}>
|
<Button type='submit' onClick={() => onSave({ title, text: content })}>
|
||||||
<Icon name="save"/> Submit
|
<Icon name="save"/> Submit
|
||||||
</Button>
|
</Button>
|
||||||
</Form>
|
</Form>
|
||||||
|
@ -17,20 +17,11 @@ export async function start() {
|
|||||||
window.ipfs = new IPFS({
|
window.ipfs = new IPFS({
|
||||||
repo: 'ipfs-v6-boards-v0',
|
repo: 'ipfs-v6-boards-v0',
|
||||||
EXPERIMENTAL: {
|
EXPERIMENTAL: {
|
||||||
pubsub: true
|
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'
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
await new Promise(fullfill => {
|
await new Promise(resolve => {
|
||||||
window.ipfs.on('ready', () => fullfill())
|
window.ipfs.on('ready', () => resolve())
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
if (!window.orbitDb) {
|
if (!window.orbitDb) {
|
||||||
@ -40,6 +31,7 @@ export async function start() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function open(address, metadata) {
|
export async function open(address, metadata) {
|
||||||
|
if (window.dbs && window.dbs[address]) return window.dbs[address]
|
||||||
await start()
|
await start()
|
||||||
const options = {
|
const options = {
|
||||||
type: BoardStore.type,
|
type: BoardStore.type,
|
||||||
|
@ -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 { eventChannel } from 'redux-saga'
|
||||||
import { push } from 'react-router-redux'
|
import { push } from 'react-router-redux'
|
||||||
import { open, connectDb } from '../orbitdb'
|
import { open, connectDb } from '../orbitdb'
|
||||||
@ -31,7 +31,7 @@ export function* closeBoard({ address }){
|
|||||||
export function* updateBoardMetadata({ address, metadata }){
|
export function* updateBoardMetadata({ address, metadata }){
|
||||||
const db = window.dbs[address]
|
const db = window.dbs[address]
|
||||||
if (db) {
|
if (db) {
|
||||||
yield apply(db, db.updateMetadata, [metadata])
|
yield call([db, db.updateMetadata], [metadata])
|
||||||
yield goToBoard({ board: { address } });
|
yield goToBoard({ board: { address } });
|
||||||
} else {
|
} else {
|
||||||
yield put({ type: 'ERROR', error: address + ' not found' })
|
yield put({ type: 'ERROR', error: address + ' not found' })
|
||||||
|
@ -9,7 +9,6 @@ import {
|
|||||||
UPDATE_BOARD_METADATA
|
UPDATE_BOARD_METADATA
|
||||||
} from '../actions/actionTypes'
|
} from '../actions/actionTypes'
|
||||||
import { openBoard, updateBoard, goToBoard, updateBoardMetadata, closeBoard } from './boards'
|
import { openBoard, updateBoard, goToBoard, updateBoardMetadata, closeBoard } from './boards'
|
||||||
import { openBoard as openBoardAction } from '../actions/board'
|
|
||||||
import { addPost } from './posts'
|
import { addPost } from './posts'
|
||||||
import { openPreviousBoards, saveSaga } from './persistence'
|
import { openPreviousBoards, saveSaga } from './persistence'
|
||||||
|
|
||||||
|
@ -1,19 +1,18 @@
|
|||||||
import { apply, call } from 'redux-saga/effects'
|
import { call } from 'redux-saga/effects'
|
||||||
import { ipfsPut } from '../utils/ipfs'
|
|
||||||
import { goToBoard } from './boards';
|
import { goToBoard } from './boards';
|
||||||
|
|
||||||
export function* addPost({ address, post }) {
|
export function* addPost({ address, post }) {
|
||||||
const db = window.dbs[address]
|
const db = window.dbs[address]
|
||||||
const { title, text } = post
|
const { title, text } = post
|
||||||
yield apply(db, db.addPost, { title, text })
|
yield call([db, db.addPost], { title, text })
|
||||||
yield goToBoard({ board: { address } });
|
yield goToBoard({ board: { address, redirect: true } });
|
||||||
// TODO: goto post
|
// TODO: goto post
|
||||||
}
|
}
|
||||||
|
|
||||||
export function* editPost({ address, postId, post }) {
|
export function* editPost({ address, postId, post }) {
|
||||||
const db = window.dbs[address]
|
const db = window.dbs[address]
|
||||||
const { title, text } = post
|
const { title, text } = post
|
||||||
yield apply(db, db.updatePost, [postId, { title, text }])
|
yield call([db, db.updatePost], postId, { title, text })
|
||||||
yield goToBoard({ board: { address } });
|
yield goToBoard({ board: { address, redirect: true } });
|
||||||
// TODO: goto post
|
// TODO: goto post
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user