mirror of
https://github.com/wassname/talk.git
synced 2026-07-21 12:51:03 +08:00
Merge pull request #747 from coralproject/fix-permalink-live-update
Fix perma view live updates
This commit is contained in:
@@ -1,10 +1,18 @@
|
||||
import update from 'immutability-helper';
|
||||
import {THREADING_LEVEL} from '../constants/stream';
|
||||
function determineCommentDepth(comment) {
|
||||
let depth = 0;
|
||||
let cur = comment;
|
||||
while (cur.parent) {
|
||||
cur = cur.parent;
|
||||
depth++;
|
||||
}
|
||||
return depth;
|
||||
}
|
||||
|
||||
function applyToCommentsOrigin(root, callback) {
|
||||
if (root.comment) {
|
||||
let comment = root.comment;
|
||||
for (let depth = 0; depth <= THREADING_LEVEL; depth++) {
|
||||
for (let depth = 0; depth <= determineCommentDepth(comment); depth++) {
|
||||
let changes = {$apply: (node) => node ? callback(node) : node};
|
||||
for (let i = 0; i < depth; i++) {
|
||||
changes = {parent: changes};
|
||||
|
||||
Reference in New Issue
Block a user