diff options
author | Renard | 2019-09-17 17:32:18 -0300 |
---|---|---|
committer | Renard | 2019-09-17 17:32:18 -0300 |
commit | a5e3c6c7672ffc8976bd4a55d49947064d48f5a4 (patch) | |
tree | 1574d1ec7ed79419bfbcfd1b27ed483e65ce77f6 | |
parent | 6392f972f51e06a239d11caa71a5ba1714ef9632 (diff) | |
download | bai-client-a5e3c6c7672ffc8976bd4a55d49947064d48f5a4.tar.gz bai-client-a5e3c6c7672ffc8976bd4a55d49947064d48f5a4.tar.xz bai-client-a5e3c6c7672ffc8976bd4a55d49947064d48f5a4.zip |
IDs coloreados, avatar asignado por id
-rw-r--r-- | src/Post.js | 28 |
1 files changed, 24 insertions, 4 deletions
diff --git a/src/Post.js b/src/Post.js index be831a1..b3e47ea 100644 --- a/src/Post.js +++ b/src/Post.js @@ -48,13 +48,29 @@ const Post = ({ index, post, locked, threadId, currentBoard }) => { ); } + let user_id = post.timestamp_formatted.split(" ID:")[1]; const filesize = require("filesize"); const seedrandom = require("seedrandom"); const rng = seedrandom(threadId + index); + const idRng = seedrandom(user_id); + const idColor = + "rgb(" + + Math.round(idRng() * 255) + + ", " + + Math.round(idRng() * 200) + + ", " + + Math.round(idRng() * 200) + + ")"; + + let rndAvatar; + if (user_id !== "") { + let i = Math.round(idRng() * avatars.length); + rndAvatar = avatars[i]; + } else { + let i = Math.round(rng() * avatars.length); + rndAvatar = avatars[i]; + } - let user_id = post.timestamp_formatted.split(" ID:")[1]; - const i = Math.round(rng() * avatars.length); - const rndAvatar = avatars[i]; let flag; if (currentBoard.dir === "world") { @@ -115,7 +131,11 @@ const Post = ({ index, post, locked, threadId, currentBoard }) => { name="star" color={user_id === "CAP_USER*" ? "yellow" : "grey"} /> - {user_id === "CAP_USER*" ? "Usuario verificado" : user_id} + {user_id === "CAP_USER*" ? ( + "Usuario verificado" + ) : ( + <span style={{ color: idColor }}>{user_id}</span> + )} </div> </Comment.Metadata> <Comment.Text> |