mirror of
https://github.com/mastodon/mastodon.git
synced 2024-11-20 11:35:29 +01:00
Replace recursion in status mapStateToProps (#7645)
This commit is contained in:
parent
9bd23dc4e5
commit
dfbadd6837
@ -62,31 +62,28 @@ const makeMapStateToProps = () => {
|
||||
|
||||
if (status) {
|
||||
ancestorsIds = ancestorsIds.withMutations(mutable => {
|
||||
function addAncestor(id) {
|
||||
if (id) {
|
||||
const inReplyTo = state.getIn(['contexts', 'inReplyTos', id]);
|
||||
let id = status.get('in_reply_to_id');
|
||||
|
||||
while (id) {
|
||||
mutable.unshift(id);
|
||||
addAncestor(inReplyTo);
|
||||
id = state.getIn(['contexts', 'inReplyTos', id]);
|
||||
}
|
||||
}
|
||||
|
||||
addAncestor(status.get('in_reply_to_id'));
|
||||
});
|
||||
|
||||
descendantsIds = descendantsIds.withMutations(mutable => {
|
||||
function addDescendantOf(id) {
|
||||
const ids = [status.get('id')];
|
||||
|
||||
while (ids.length > 0) {
|
||||
let id = ids.shift();
|
||||
const replies = state.getIn(['contexts', 'replies', id]);
|
||||
|
||||
if (replies) {
|
||||
replies.forEach(reply => {
|
||||
mutable.push(reply);
|
||||
addDescendantOf(reply);
|
||||
ids.unshift(reply);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
addDescendantOf(status.get('id'));
|
||||
});
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user