From 37f9954f1193fc7382ca8ec98d7926910c2a56b3 Mon Sep 17 00:00:00 2001 From: Alex Date: Sat, 23 Jun 2018 22:33:18 +0300 Subject: [PATCH 01/12] #find @method -rename --- web/app/common/api.js | 6 +++--- web/app/components/root/root.jsx | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/web/app/common/api.js b/web/app/common/api.js index 566db403..db80d871 100644 --- a/web/app/common/api.js +++ b/web/app/common/api.js @@ -11,9 +11,9 @@ export const logOut = () => fetcher.get({ url: `/auth/logout`, overriddenApiBase export const getConfig = () => fetcher.get(`/config`); // TODO: looks like we can get url from settings here and below -export const find = ({ sort, url }) => fetcher.get(`/find?url=${url}&sort=${sort}&format=tree`); +export const getPostComments = ({ sort, url }) => fetcher.get(`/find?url=${url}&sort=${sort}&format=tree`); -export const last = ({ siteId, max }) => fetcher.get(`/last/${max}?site=${siteId}`); +export const getLastComments = ({ siteId, max }) => fetcher.get(`/last/${max}?site=${siteId}`); export const counts = ({ urls, siteId }) => fetcher.post({ url: `/counts?site=${siteId}`, @@ -107,7 +107,7 @@ export const getBlocked = () => fetcher.get({ export default { logOut, getConfig, - find, + getPostComments, last, counts, getComment, diff --git a/web/app/components/root/root.jsx b/web/app/components/root/root.jsx index 4ac23048..2428b663 100644 --- a/web/app/components/root/root.jsx +++ b/web/app/components/root/root.jsx @@ -62,7 +62,7 @@ export default class Root extends Component { api.getUser() .then(data => store.set('user', data)) .catch(() => store.set('user', {})), - api.find({ sort, url }) + api.getPostComments({ sort, url }) .then(({ comments = [] } = {}) => store.set('comments', comments)) .catch(() => store.set('comments', [])), ]).finally(() => { @@ -133,7 +133,7 @@ export default class Root extends Component { // if someone was unblocked let's reload comments if (wasSomeoneUnblocked) { - api.find({ sort, url }).then(({ comments } = {}) => store.set('comments', comments)); + api.getPostComments({ sort, url }).then(({ comments } = {}) => store.set('comments', comments)); } this.setState({ @@ -153,7 +153,7 @@ export default class Root extends Component { // can't save; ignore it } - api.find({ sort, url }) + api.getPostComments({ sort, url }) .then(({ comments } = {}) => store.set('comments', comments)) .finally(() => { this.setState({ isCommentsListLoading: false }); From 83d3afa2911c0f75dee5e158b202633e5bca7da4 Mon Sep 17 00:00:00 2001 From: Alex Date: Sat, 23 Jun 2018 22:38:55 +0300 Subject: [PATCH 02/12] #last @method -rename --- web/app/common/api.js | 2 +- web/app/last-comments.js | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/web/app/common/api.js b/web/app/common/api.js index db80d871..dc74374b 100644 --- a/web/app/common/api.js +++ b/web/app/common/api.js @@ -108,7 +108,7 @@ export default { logOut, getConfig, getPostComments, - last, + getLastComments, counts, getComment, getUserComments, diff --git a/web/app/last-comments.js b/web/app/last-comments.js index c83c6e8a..c70826be 100644 --- a/web/app/last-comments.js +++ b/web/app/last-comments.js @@ -5,6 +5,7 @@ import { BASE_URL, DEFAULT_LAST_COMMENTS_MAX, LAST_COMMENTS_NODE_CLASSNAME } fro import api from 'common/api'; import ListComments from 'components/list-comments'; +import {getLastComments} from "./common/api"; if (document.readyState === 'loading') { document.addEventListener('DOMContentLoaded', init); @@ -39,7 +40,7 @@ function init() { [].slice.call(nodes).forEach(node => { const max = node.dataset.max || remark_config.max_last_comments || DEFAULT_LAST_COMMENTS_MAX; - api.last({ max, siteId: remark_config.site_id }) + api.getLastComments({ max, siteId: remark_config.site_id }) .then(comments => { try { render(, node); From 17529d0646a11e4d4e31c5b630f5ed8834dd9238 Mon Sep 17 00:00:00 2001 From: Alex Date: Sat, 23 Jun 2018 22:51:14 +0300 Subject: [PATCH 03/12] #counts @method -rename --- web/app/common/api.js | 4 ++-- web/app/counter.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/web/app/common/api.js b/web/app/common/api.js index dc74374b..93683572 100644 --- a/web/app/common/api.js +++ b/web/app/common/api.js @@ -15,7 +15,7 @@ export const getPostComments = ({ sort, url }) => fetcher.get(`/find?url=${url}& export const getLastComments = ({ siteId, max }) => fetcher.get(`/last/${max}?site=${siteId}`); -export const counts = ({ urls, siteId }) => fetcher.post({ +export const getCommentsCount = ({ urls, siteId }) => fetcher.post({ url: `/counts?site=${siteId}`, body: urls, }); @@ -109,7 +109,7 @@ export default { getConfig, getPostComments, getLastComments, - counts, + getCommentsCount, getComment, getUserComments, vote, diff --git a/web/app/counter.js b/web/app/counter.js index 2c850233..3d0dd7df 100644 --- a/web/app/counter.js +++ b/web/app/counter.js @@ -33,7 +33,7 @@ function init() { return acc; }, {}); - api.counts({ urls: Object.keys(map), siteId: remark_config.site_id }) + api.getCommentsCount({ urls: Object.keys(map), siteId: remark_config.site_id }) .then(res => { res.forEach(item => (map[item.url].innerHTML = item.count)); }); From 7e27cf5060cf1e864bf5588e156bda4ef50319c4 Mon Sep 17 00:00:00 2001 From: Alex Date: Sat, 23 Jun 2018 22:53:22 +0300 Subject: [PATCH 04/12] #vote @method -rename --- web/app/common/api.js | 4 ++-- web/app/components/comment/comment.jsx | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/web/app/common/api.js b/web/app/common/api.js index 93683572..f8afcbbb 100644 --- a/web/app/common/api.js +++ b/web/app/common/api.js @@ -24,7 +24,7 @@ export const getComment = ({ id }) => fetcher.get(`/id/${id}?url=${url}`); export const getUserComments = ({ user, limit }) => fetcher.get(`/comments?user=${user}&limit=${limit}`); -export const vote = ({ id, url, value }) => fetcher.put({ +export const putCommentVote = ({ id, url, value }) => fetcher.put({ url: `/vote/${id}?url=${url}&vote=${value}`, withCredentials: true, }); @@ -112,7 +112,7 @@ export default { getCommentsCount, getComment, getUserComments, - vote, + putCommentVote, send, edit, getUser, diff --git a/web/app/components/comment/comment.jsx b/web/app/components/comment/comment.jsx index 02870a14..72fd8924 100644 --- a/web/app/components/comment/comment.jsx +++ b/web/app/components/comment/comment.jsx @@ -233,7 +233,7 @@ export default class Comment extends Component { this.votingPromise = this.votingPromise .then(() => { - return api.vote({ id, url, value: 1 }) + return api.putCommentVote({ id, url, value: 1 }) .then(() => { api.getComment({ id }).then(comment => store.replaceComment(comment)); }); @@ -254,7 +254,7 @@ export default class Comment extends Component { this.votingPromise = this.votingPromise .then(() => { - return api.vote({ id, url, value: -1 }) + return api.putCommentVote({ id, url, value: -1 }) .then(() => { api.getComment({ id }).then(comment => store.replaceComment(comment)); }); From 48bcadbceb7ab4ffe556b8982c2c612743eed702 Mon Sep 17 00:00:00 2001 From: Alex Date: Sat, 23 Jun 2018 22:56:54 +0300 Subject: [PATCH 05/12] #send @method -rename --- web/app/common/api.js | 6 +++--- web/app/components/input/input.jsx | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/web/app/common/api.js b/web/app/common/api.js index f8afcbbb..ec09e7bf 100644 --- a/web/app/common/api.js +++ b/web/app/common/api.js @@ -29,7 +29,7 @@ export const putCommentVote = ({ id, url, value }) => fetcher.put({ withCredentials: true, }); -export const send = ({ text, pid }) => fetcher.post({ +export const addComment = ({ text, pid }) => fetcher.post({ url: '/comment', body: { text, @@ -112,8 +112,8 @@ export default { getCommentsCount, getComment, getUserComments, - putCommentVote, - send, + putCommentVote, + addComment, edit, getUser, getPreview, diff --git a/web/app/components/input/input.jsx b/web/app/components/input/input.jsx index 6b080c28..fd0f7c96 100644 --- a/web/app/components/input/input.jsx +++ b/web/app/components/input/input.jsx @@ -94,7 +94,7 @@ export default class Input extends Component { const request = mods.mode === 'edit' ? api.edit({ text, id }) - : api.send({ text, ...(pid ? { pid } : {}) }); + : api.addComment({ text, ...(pid ? { pid } : {}) }); request .then(comment => { From 0171fc85b54e00563b68f513c39ed422ebd9b247 Mon Sep 17 00:00:00 2001 From: Alex Date: Sat, 23 Jun 2018 22:57:46 +0300 Subject: [PATCH 06/12] #edit @method -rename --- web/app/common/api.js | 4 ++-- web/app/components/input/input.jsx | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/web/app/common/api.js b/web/app/common/api.js index ec09e7bf..920d4996 100644 --- a/web/app/common/api.js +++ b/web/app/common/api.js @@ -42,7 +42,7 @@ export const addComment = ({ text, pid }) => fetcher.post({ withCredentials: true, }); -export const edit = ({ text, id }) => fetcher.put({ +export const updateComment = ({ text, id }) => fetcher.put({ url: `/comment/${id}?url=${url}`, body: { text, @@ -114,7 +114,7 @@ export default { getUserComments, putCommentVote, addComment, - edit, + updateComment, getUser, getPreview, diff --git a/web/app/components/input/input.jsx b/web/app/components/input/input.jsx index fd0f7c96..7486ebaf 100644 --- a/web/app/components/input/input.jsx +++ b/web/app/components/input/input.jsx @@ -93,7 +93,7 @@ export default class Input extends Component { this.setState({ isDisabled: true, isErrorShown: false }); const request = mods.mode === 'edit' - ? api.edit({ text, id }) + ? api.updateComment({ text, id }) : api.addComment({ text, ...(pid ? { pid } : {}) }); request From 7b7934e93ce64e9ba8f94e46d1de4a02e9d0109b Mon Sep 17 00:00:00 2001 From: Alex Date: Sat, 23 Jun 2018 23:00:02 +0300 Subject: [PATCH 07/12] #pin @method -rename --- web/app/common/api.js | 4 ++-- web/app/components/comment/comment.jsx | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/web/app/common/api.js b/web/app/common/api.js index 920d4996..3047fc21 100644 --- a/web/app/common/api.js +++ b/web/app/common/api.js @@ -64,7 +64,7 @@ export const getUser = () => fetcher.get({ }); /* admin */ -export const pin = ({ id, url }) => fetcher.put({ +export const pinComment = ({ id, url }) => fetcher.put({ url: `/admin/pin/${id}?url=${url}&pin=1`, withCredentials: true, }); @@ -118,7 +118,7 @@ export default { getUser, getPreview, - pin, + pinComment, unpin, verify, unverify, diff --git a/web/app/components/comment/comment.jsx b/web/app/components/comment/comment.jsx index 72fd8924..6a49335d 100644 --- a/web/app/components/comment/comment.jsx +++ b/web/app/components/comment/comment.jsx @@ -137,7 +137,7 @@ export default class Comment extends Component { if (confirm('Do you want to pin this comment?')) { this.setState({ pinned: true }); - api.pin({ id, url }).then(() => { + api.pinComment({ id, url }).then(() => { api.getComment({ id }).then(comment => store.replaceComment(comment)); }); } From 400905c8ff163f340df10eec1a0d4ef36a460823 Mon Sep 17 00:00:00 2001 From: Alex Date: Sat, 23 Jun 2018 23:09:52 +0300 Subject: [PATCH 08/12] #unpin @method -rename --- web/app/common/api.js | 4 ++-- web/app/components/comment/comment.jsx | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/web/app/common/api.js b/web/app/common/api.js index 3047fc21..614bf0e0 100644 --- a/web/app/common/api.js +++ b/web/app/common/api.js @@ -69,7 +69,7 @@ export const pinComment = ({ id, url }) => fetcher.put({ withCredentials: true, }); -export const unpin = ({ id, url }) => fetcher.put({ +export const unpinComment = ({ id, url }) => fetcher.put({ url: `/admin/pin/${id}?url=${url}&pin=0`, withCredentials: true, }); @@ -119,7 +119,7 @@ export default { getPreview, pinComment, - unpin, + unpinComment, verify, unverify, remove, diff --git a/web/app/components/comment/comment.jsx b/web/app/components/comment/comment.jsx index 6a49335d..7bbb80f3 100644 --- a/web/app/components/comment/comment.jsx +++ b/web/app/components/comment/comment.jsx @@ -149,7 +149,7 @@ export default class Comment extends Component { if (confirm('Do you want to unpin this comment?')) { this.setState({ pinned: false }); - api.unpin({ id, url }).then(() => { + api.unpinComment({ id, url }).then(() => { api.getComment({ id }).then(comment => store.replaceComment(comment)); }); } From 72f1f774f51dc9d0478257b16ca964a3a3d8e8f2 Mon Sep 17 00:00:00 2001 From: Alex Date: Sat, 23 Jun 2018 23:11:34 +0300 Subject: [PATCH 09/12] #verify @method -rename --- web/app/common/api.js | 4 ++-- web/app/components/comment/comment.jsx | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/web/app/common/api.js b/web/app/common/api.js index 614bf0e0..08542303 100644 --- a/web/app/common/api.js +++ b/web/app/common/api.js @@ -74,7 +74,7 @@ export const unpinComment = ({ id, url }) => fetcher.put({ withCredentials: true, }); -export const verify = ({ id }) => fetcher.put({ +export const setVerifyStatus = ({ id }) => fetcher.put({ url: `/admin/verify/${id}?verified=1`, withCredentials: true, }); @@ -120,7 +120,7 @@ export default { pinComment, unpinComment, - verify, + setVerifyStatus, unverify, remove, blockUser, diff --git a/web/app/components/comment/comment.jsx b/web/app/components/comment/comment.jsx index 7bbb80f3..7a13264e 100644 --- a/web/app/components/comment/comment.jsx +++ b/web/app/components/comment/comment.jsx @@ -161,7 +161,7 @@ export default class Comment extends Component { if (confirm('Do you want to verify this user?')) { this.setState({ isUserVerified: true }); - api.verify({ id: userId }).then(() => { + api.setVerifyStatus({ id: userId }).then(() => { api.getComment({ id }).then(comment => store.replaceComment(comment)); }); } From 73d875f4778f7e53e602399177131d5e7554fb5d Mon Sep 17 00:00:00 2001 From: Alex Date: Sat, 23 Jun 2018 23:12:31 +0300 Subject: [PATCH 10/12] #unverify @method -rename --- web/app/common/api.js | 4 ++-- web/app/components/comment/comment.jsx | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/web/app/common/api.js b/web/app/common/api.js index 08542303..bdbc4c13 100644 --- a/web/app/common/api.js +++ b/web/app/common/api.js @@ -79,7 +79,7 @@ export const setVerifyStatus = ({ id }) => fetcher.put({ withCredentials: true, }); -export const unverify = ({ id }) => fetcher.put({ +export const removeVerifyStatus = ({ id }) => fetcher.put({ url: `/admin/verify/${id}?verified=0`, withCredentials: true, }); @@ -121,7 +121,7 @@ export default { pinComment, unpinComment, setVerifyStatus, - unverify, + removeVerifyStatus, remove, blockUser, unblockUser, diff --git a/web/app/components/comment/comment.jsx b/web/app/components/comment/comment.jsx index 7a13264e..1bc0188b 100644 --- a/web/app/components/comment/comment.jsx +++ b/web/app/components/comment/comment.jsx @@ -173,7 +173,7 @@ export default class Comment extends Component { if (confirm('Do you want to unverify this user?')) { this.setState({ isUserVerified: false }); - api.unverify({ id: userId }).then(() => { + api.removeVerifyStatus({ id: userId }).then(() => { api.getComment({ id }).then(comment => store.replaceComment(comment)); }); } From 0b36b79d161cf41470124c0f811c6e006c2fd632 Mon Sep 17 00:00:00 2001 From: Alex Date: Sat, 23 Jun 2018 23:13:45 +0300 Subject: [PATCH 11/12] #remove @method -rename --- web/app/common/api.js | 4 ++-- web/app/components/comment/comment.jsx | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/web/app/common/api.js b/web/app/common/api.js index bdbc4c13..a067fc1c 100644 --- a/web/app/common/api.js +++ b/web/app/common/api.js @@ -84,7 +84,7 @@ export const removeVerifyStatus = ({ id }) => fetcher.put({ withCredentials: true, }); -export const remove = ({ id }) => fetcher.delete({ +export const removeComment = ({ id }) => fetcher.delete({ url: `/admin/comment/${id}?url=${url}`, withCredentials: true, }); @@ -122,7 +122,7 @@ export default { unpinComment, setVerifyStatus, removeVerifyStatus, - remove, + removeComment, blockUser, unblockUser, getBlocked, diff --git a/web/app/components/comment/comment.jsx b/web/app/components/comment/comment.jsx index 1bc0188b..39d8ede2 100644 --- a/web/app/components/comment/comment.jsx +++ b/web/app/components/comment/comment.jsx @@ -213,7 +213,7 @@ export default class Comment extends Component { isReplying: false, }); - api.remove({ id }).then(() => { + api.removeComment({ id }).then(() => { api.getComment({ id }).then(comment => store.replaceComment(comment)); }); } From 76c7ea13d32c6b69ac79e441681e2b093427ed63 Mon Sep 17 00:00:00 2001 From: Alex Date: Sat, 23 Jun 2018 23:15:56 +0300 Subject: [PATCH 12/12] #import @method -fix --- web/app/last-comments.js | 1 - 1 file changed, 1 deletion(-) diff --git a/web/app/last-comments.js b/web/app/last-comments.js index c70826be..ddf31a89 100644 --- a/web/app/last-comments.js +++ b/web/app/last-comments.js @@ -5,7 +5,6 @@ import { BASE_URL, DEFAULT_LAST_COMMENTS_MAX, LAST_COMMENTS_NODE_CLASSNAME } fro import api from 'common/api'; import ListComments from 'components/list-comments'; -import {getLastComments} from "./common/api"; if (document.readyState === 'loading') { document.addEventListener('DOMContentLoaded', init);