1
0
mirror of https://github.com/fazo96/ipfs-boards synced 2025-01-09 12:19:49 +01:00

WIP editing and comments

This commit is contained in:
Enrico Fasoli 2018-03-06 18:24:39 +01:00
parent 0aab7ce88d
commit 6eaebebcf7
No known key found for this signature in database
GPG Key ID: 1238873C5F27DB4D
5 changed files with 98 additions and 6 deletions

View File

@ -1,7 +1,13 @@
export const ADD_POST = 'ADD_POST' export const ADD_POST = 'ADD_POST'
export const EDIT_POST = 'EDIT_POST'
export const HIDE_POST = 'HIDE_POST'
export const UPDATE_BOARD_METADATA = 'UPDATE_BOARD_METADATA' export const UPDATE_BOARD_METADATA = 'UPDATE_BOARD_METADATA'
export const ADD_COMMENT = 'ADD_COMMENT'
export const EDIT_COMMENT = 'EDIT_COMMENT'
export const HIDE_COMMENT = 'HIDE_COMMENT'
export const OPEN_BOARD = 'OPEN_BOARD' export const OPEN_BOARD = 'OPEN_BOARD'
export const OPENED_BOARD = 'OPENED_BOARD' export const OPENED_BOARD = 'OPENED_BOARD'
export const CLOSE_BOARD = 'CLOSE_BOARD' export const CLOSE_BOARD = 'CLOSE_BOARD'

32
src/actions/comment.js Normal file
View File

@ -0,0 +1,32 @@
import { HIDE_COMMENT, ADD_COMMENT, EDIT_COMMENT } from './actionTypes'
export function addComment(address, postId, comment, replyTo = 'post') {
return {
type: ADD_COMMENT,
address,
postId,
comment,
replyTo
}
}
export function editComment(address, postId, commentId, comment, replyTo = 'post') {
return {
type: EDIT_COMMENT,
address,
postId,
commentId,
comment,
replyTo
}
}
export function hideComment(address, postId, commentId, replyTo = 'post') {
return {
type: HIDE_COMMENT,
address,
postId,
commentId,
replyTo
}
}

View File

@ -1,4 +1,4 @@
import { ADD_POST } from './actionTypes' import { ADD_POST, EDIT_POST, HIDE_POST } from './actionTypes'
export function addPost(address, post) { export function addPost(address, post) {
return { return {
@ -6,4 +6,21 @@ export function addPost(address, post) {
post, post,
address address
} }
}
export function editPost(address, postId, post) {
return {
type: EDIT_POST,
address,
postId,
post,
}
}
export function hidePost(address, postId) {
return {
type: HIDE_POST,
address,
postId
}
} }

View File

@ -4,8 +4,24 @@ 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, content } = post const { title, text } = post
const multihash = yield call(ipfsPut, content) yield apply(db, db.addPost, { title, text })
yield apply(db, db.addPost, [title, multihash])
yield goToBoard({ board: { address } }); yield goToBoard({ board: { address } });
// 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 } });
// 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 } });
// TODO: goto post
} }

View File

@ -5599,6 +5599,10 @@ lodash.values@^4.3.0:
version "4.17.4" version "4.17.4"
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.4.tgz#78203a4d1c328ae1d86dca6460e369b57f4055ae" resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.4.tgz#78203a4d1c328ae1d86dca6460e369b57f4055ae"
lodash@^4.17.5:
version "4.17.5"
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.5.tgz#99a92d65c0272debe8c96b6057bc8fbfa3bed511"
loglevel@^1.4.1: loglevel@^1.4.1:
version "1.6.1" version "1.6.1"
resolved "https://registry.yarnpkg.com/loglevel/-/loglevel-1.6.1.tgz#e0fc95133b6ef276cdc8887cdaf24aa6f156f8fa" resolved "https://registry.yarnpkg.com/loglevel/-/loglevel-1.6.1.tgz#e0fc95133b6ef276cdc8887cdaf24aa6f156f8fa"
@ -6279,8 +6283,9 @@ orbit-db-counterstore@~1.2.0:
"orbit-db-discussion-board@https://github.com/fazo96/orbit-db-discussion-board.git": "orbit-db-discussion-board@https://github.com/fazo96/orbit-db-discussion-board.git":
version "0.1.0" version "0.1.0"
resolved "https://github.com/fazo96/orbit-db-discussion-board.git#b71b93f2415a867f8ed29cc76fe7af0e9fb570ce" resolved "https://github.com/fazo96/orbit-db-discussion-board.git#71a51f52760523c730fdaa0487810fe983590ab3"
dependencies: dependencies:
lodash "^4.17.5"
orbit-db-store "^2.2.1" orbit-db-store "^2.2.1"
orbit-db-docstore@~1.2.0: orbit-db-docstore@~1.2.0:
@ -7018,6 +7023,10 @@ process-nextick-args@~1.0.6:
version "1.0.7" version "1.0.7"
resolved "https://registry.yarnpkg.com/process-nextick-args/-/process-nextick-args-1.0.7.tgz#150e20b756590ad3f91093f25a4f2ad8bff30ba3" resolved "https://registry.yarnpkg.com/process-nextick-args/-/process-nextick-args-1.0.7.tgz#150e20b756590ad3f91093f25a4f2ad8bff30ba3"
process-nextick-args@~2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/process-nextick-args/-/process-nextick-args-2.0.0.tgz#a37d732f4271b4ab1ad070d35508e8290788ffaa"
process@^0.11.10: process@^0.11.10:
version "0.11.10" version "0.11.10"
resolved "https://registry.yarnpkg.com/process/-/process-0.11.10.tgz#7332300e840161bda3e69a1d1d91a7d4bc16f182" resolved "https://registry.yarnpkg.com/process/-/process-0.11.10.tgz#7332300e840161bda3e69a1d1d91a7d4bc16f182"
@ -7582,7 +7591,7 @@ readable-stream@1.1.x, readable-stream@^1.0.33:
isarray "0.0.1" isarray "0.0.1"
string_decoder "~0.10.x" string_decoder "~0.10.x"
readable-stream@2.3.3, readable-stream@^2.0.0, readable-stream@^2.0.1, readable-stream@^2.0.2, readable-stream@^2.0.5, readable-stream@^2.0.6, readable-stream@^2.1.4, readable-stream@^2.1.5, readable-stream@^2.2.2, readable-stream@^2.2.9, readable-stream@^2.3.3, readable-stream@~2.3.3: readable-stream@2.3.3, readable-stream@^2.0.0, readable-stream@^2.0.1, readable-stream@^2.0.2, readable-stream@^2.0.5, readable-stream@^2.0.6, readable-stream@^2.1.4, readable-stream@^2.1.5, readable-stream@^2.2.2, readable-stream@^2.2.9, readable-stream@^2.3.3:
version "2.3.3" version "2.3.3"
resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-2.3.3.tgz#368f2512d79f9d46fdfc71349ae7878bbc1eb95c" resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-2.3.3.tgz#368f2512d79f9d46fdfc71349ae7878bbc1eb95c"
dependencies: dependencies:
@ -7594,6 +7603,18 @@ readable-stream@2.3.3, readable-stream@^2.0.0, readable-stream@^2.0.1, readable-
string_decoder "~1.0.3" string_decoder "~1.0.3"
util-deprecate "~1.0.1" util-deprecate "~1.0.1"
readable-stream@~2.3.3:
version "2.3.5"
resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-2.3.5.tgz#b4f85003a938cbb6ecbce2a124fb1012bd1a838d"
dependencies:
core-util-is "~1.0.0"
inherits "~2.0.3"
isarray "~1.0.0"
process-nextick-args "~2.0.0"
safe-buffer "~5.1.1"
string_decoder "~1.0.3"
util-deprecate "~1.0.1"
readdirp@^2.0.0: readdirp@^2.0.0:
version "2.1.0" version "2.1.0"
resolved "https://registry.yarnpkg.com/readdirp/-/readdirp-2.1.0.tgz#4ed0ad060df3073300c48440373f72d1cc642d78" resolved "https://registry.yarnpkg.com/readdirp/-/readdirp-2.1.0.tgz#4ed0ad060df3073300c48440373f72d1cc642d78"