diff --git a/src/actions/actionTypes.js b/src/actions/actionTypes.js index 1170cd2..e74a2fd 100644 --- a/src/actions/actionTypes.js +++ b/src/actions/actionTypes.js @@ -1,7 +1,13 @@ 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 ADD_COMMENT = 'ADD_COMMENT' +export const EDIT_COMMENT = 'EDIT_COMMENT' +export const HIDE_COMMENT = 'HIDE_COMMENT' + export const OPEN_BOARD = 'OPEN_BOARD' export const OPENED_BOARD = 'OPENED_BOARD' export const CLOSE_BOARD = 'CLOSE_BOARD' diff --git a/src/actions/comment.js b/src/actions/comment.js new file mode 100644 index 0000000..0732da6 --- /dev/null +++ b/src/actions/comment.js @@ -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 + } +} \ No newline at end of file diff --git a/src/actions/post.js b/src/actions/post.js index 380c2bf..31f9c48 100644 --- a/src/actions/post.js +++ b/src/actions/post.js @@ -1,4 +1,4 @@ -import { ADD_POST } from './actionTypes' +import { ADD_POST, EDIT_POST, HIDE_POST } from './actionTypes' export function addPost(address, post) { return { @@ -6,4 +6,21 @@ export function addPost(address, post) { post, 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 + } } \ No newline at end of file diff --git a/src/sagas/posts.js b/src/sagas/posts.js index bd9a06f..9148306 100644 --- a/src/sagas/posts.js +++ b/src/sagas/posts.js @@ -4,8 +4,24 @@ import { goToBoard } from './boards'; export function* addPost({ address, post }) { const db = window.dbs[address] - const { title, content } = post - const multihash = yield call(ipfsPut, content) - yield apply(db, db.addPost, [title, multihash]) + const { title, text } = post + yield apply(db, db.addPost, { 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 +} + +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 } \ No newline at end of file diff --git a/yarn.lock b/yarn.lock index c8ad03a..54fce27 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5599,6 +5599,10 @@ lodash.values@^4.3.0: version "4.17.4" 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: version "1.6.1" 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": 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: + lodash "^4.17.5" orbit-db-store "^2.2.1" orbit-db-docstore@~1.2.0: @@ -7018,6 +7023,10 @@ process-nextick-args@~1.0.6: version "1.0.7" 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: version "0.11.10" 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" 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" resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-2.3.3.tgz#368f2512d79f9d46fdfc71349ae7878bbc1eb95c" 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" 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: version "2.1.0" resolved "https://registry.yarnpkg.com/readdirp/-/readdirp-2.1.0.tgz#4ed0ad060df3073300c48440373f72d1cc642d78"