aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Post.js30
-rw-r--r--src/ReplyForm.js21
2 files changed, 44 insertions, 7 deletions
diff --git a/src/Post.js b/src/Post.js
index 8193ec1..54e56e7 100644
--- a/src/Post.js
+++ b/src/Post.js
@@ -155,6 +155,30 @@ const Post = ({ index, post, locked, threadId, currentBoard, nightMode }) => {
);
const youtubeVideos = post.message.match(youtubeRe);
+ // El post es nuestro?
+ const ownPosts = JSON.parse(localStorage.getItem("ownPosts"));
+ let isMine = false;
+ if (ownPosts !== null) {
+ if (Object.prototype.hasOwnProperty.call(ownPosts, currentBoard.dir)) {
+ ownPosts[currentBoard.dir].forEach(reply => {
+ if (reply.thread_id === post.parentid) {
+ if (reply.reply_id === post.id) {
+ isMine = true;
+ }
+ }
+ });
+ }
+ }
+
+ let starColor;
+ if (user_id === "CAP_USER*") {
+ starColor = "yellow";
+ } else if (isMine) {
+ starColor = "blue";
+ } else {
+ starColor = "gray";
+ }
+
return (
<Comment inverted={nightMode}>
<Comment.Avatar
@@ -182,15 +206,13 @@ const Post = ({ index, post, locked, threadId, currentBoard, nightMode }) => {
<Moment fromNow unix locale="es" date={post.timestamp} />
</div>
<div>
- <Icon
- name="star"
- color={user_id === "CAP_USER*" ? "yellow" : "grey"}
- />
+ <Icon name="star" color={starColor} />
{user_id === "CAP_USER*" ? (
"Usuario verificado"
) : (
<span style={{ color: idColor }}>{user_id}</span>
)}
+ {isMine ? " (TĂș)" : null}
</div>
</Comment.Metadata>
<Comment.Text>
diff --git a/src/ReplyForm.js b/src/ReplyForm.js
index 48be8e8..0b01029 100644
--- a/src/ReplyForm.js
+++ b/src/ReplyForm.js
@@ -40,13 +40,15 @@ class ReplyForm extends Component {
{
submittedName: name,
submittedEmail: email,
- submittedMessage: message
+ submittedMessage: message,
+ replyRes: null
},
() => {
const { submittedName, submittedEmail, submittedMessage } = this.state;
+ const { currentBoard, parent } = this.props;
const data = {
- board: this.props.currentBoard.dir,
- parent: this.props.parent,
+ board: currentBoard.dir,
+ parent: parent,
name: "",
email: "",
fielda: submittedName,
@@ -75,6 +77,19 @@ class ReplyForm extends Component {
.then(resource => {
if (resource.state === "success") {
this.setState({ replyRes: resource, message: "" });
+ let ownPosts = JSON.parse(localStorage.getItem("ownPosts"));
+ if (ownPosts === null) {
+ ownPosts = {};
+ }
+ // eslint-disable-next-line no-prototype-builtins
+ if (!ownPosts.hasOwnProperty(currentBoard.dir)) {
+ ownPosts[currentBoard.dir] = [];
+ }
+ ownPosts[currentBoard.dir] = ownPosts[currentBoard.dir].concat({
+ thread_id: parent,
+ reply_id: resource.post_id
+ });
+ localStorage.setItem("ownPosts", JSON.stringify(ownPosts));
}
});
}