From fe5791e98cd5ed57692e4fbc37e0b7d05fc85096 Mon Sep 17 00:00:00 2001 From: Christian Bundy Date: Fri, 27 Sep 2019 11:40:00 -0700 Subject: [PATCH] Change thread indentation to be more consistent --- src/pages/models/post.js | 3 ++- src/pages/views/components/post.js | 7 ++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/pages/models/post.js b/src/pages/models/post.js index 0e17e7a..f3fc794 100644 --- a/src/pages/models/post.js +++ b/src/pages/models/post.js @@ -377,10 +377,11 @@ const post = { return Promise.all(replies.map(async (reply) => { const deeperReplies = await oneDeeper(reply.key, depth + 1) lodash.set(reply, 'value.meta.thread.depth', depth) + lodash.set(reply, 'value.meta.thread.reply', true) return [reply, deeperReplies] })) } - oneDeeper(key, 1).then((nested) => { + oneDeeper(key, 0).then((nested) => { const nestedReplies = [...nested] const deepReplies = flattenDeep(nestedReplies) resolve(deepReplies) diff --git a/src/pages/views/components/post.js b/src/pages/views/components/post.js index a6752d0..ef719af 100644 --- a/src/pages/views/components/post.js +++ b/src/pages/views/components/post.js @@ -44,6 +44,11 @@ module.exports = ({ msg }) => { 'value.meta.thread.target', false )) + const isReply = Boolean(lodash.get( + msg, + 'value.meta.thread.reply', + false + )) const { name } = msg.value.meta.author const timeAgo = msg.value.meta.timestamp.received.since @@ -74,7 +79,7 @@ module.exports = ({ msg }) => { messageClasses.push('thread-target') } - if (depth > 0) { + if (isReply) { messageClasses.push('reply') }