Fixed issue with comment indenting
• Fixed: - issue with comment indenting
This commit is contained in:
parent
a5deda528d
commit
59af6fb27f
@ -73,17 +73,23 @@ const sortReplies = (replyIds, state, type) => {
|
|||||||
|
|
||||||
const getDescendants = (state, status, highlightStatusId, commentSortingType) => {
|
const getDescendants = (state, status, highlightStatusId, commentSortingType) => {
|
||||||
let descendantsIds = ImmutableList()
|
let descendantsIds = ImmutableList()
|
||||||
let indent = -1
|
|
||||||
let index = 0
|
let index = 0
|
||||||
|
const MAX_INDENT = 2
|
||||||
|
|
||||||
descendantsIds = descendantsIds.withMutations(mutable => {
|
descendantsIds = descendantsIds.withMutations((mutable) => {
|
||||||
const ids = [status.get('id')]
|
const ids = [{
|
||||||
|
id: status.get('id'),
|
||||||
|
indent: -1,
|
||||||
|
}]
|
||||||
|
|
||||||
while (ids.length > 0) {
|
while (ids.length > 0) {
|
||||||
let id = ids.shift()
|
let block = ids.shift()
|
||||||
|
let id = block.id
|
||||||
|
let indent = block.indent
|
||||||
|
|
||||||
let replies = state.getIn(['contexts', 'replies', id])
|
let replies = state.getIn(['contexts', 'replies', id])
|
||||||
// Sort only Top-level replies
|
|
||||||
|
// Sort only Top-level replies (if original status not comment)
|
||||||
if (index === 0) {
|
if (index === 0) {
|
||||||
replies = sortReplies(replies, state, commentSortingType)
|
replies = sortReplies(replies, state, commentSortingType)
|
||||||
}
|
}
|
||||||
@ -97,13 +103,15 @@ const getDescendants = (state, status, highlightStatusId, commentSortingType) =>
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (replies) {
|
if (replies) {
|
||||||
replies.reverse().forEach(reply => {
|
|
||||||
ids.unshift(reply)
|
|
||||||
});
|
|
||||||
indent++
|
indent++
|
||||||
indent = Math.min(2, indent)
|
indent = Math.min(MAX_INDENT, indent)
|
||||||
} else {
|
|
||||||
indent = 0 // reset
|
replies.reverse().forEach((reply) => {
|
||||||
|
ids.unshift({
|
||||||
|
id: reply,
|
||||||
|
indent: indent,
|
||||||
|
})
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
index++
|
index++
|
||||||
|
Loading…
Reference in New Issue
Block a user