sforkowany z mirror/soapbox
Status: protect against infinite context loops
rodzic
b9febfc1a3
commit
b76bb097f2
|
@ -80,7 +80,7 @@ const makeMapStateToProps = () => {
|
|||
let ancestorsIds = ImmutableOrderedSet();
|
||||
let id = statusId;
|
||||
|
||||
while (id) {
|
||||
while (id && !ancestorsIds.includes(id)) {
|
||||
ancestorsIds = ImmutableOrderedSet([id]).union(ancestorsIds);
|
||||
id = inReplyTos.get(id);
|
||||
}
|
||||
|
@ -99,6 +99,10 @@ const makeMapStateToProps = () => {
|
|||
const id = ids.shift();
|
||||
const replies = contextReplies.get(id);
|
||||
|
||||
if (descendantsIds.includes(id)) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (statusId !== id) {
|
||||
descendantsIds = descendantsIds.union([id]);
|
||||
}
|
||||
|
@ -119,8 +123,11 @@ const makeMapStateToProps = () => {
|
|||
let descendantsIds = ImmutableOrderedSet();
|
||||
|
||||
if (status) {
|
||||
ancestorsIds = getAncestorsIds(state, { id: state.getIn(['contexts', 'inReplyTos', status.get('id')]) });
|
||||
descendantsIds = getDescendantsIds(state, { id: status.get('id') });
|
||||
const statusId = status.get('id');
|
||||
ancestorsIds = getAncestorsIds(state, { id: state.getIn(['contexts', 'inReplyTos', statusId]) });
|
||||
descendantsIds = getDescendantsIds(state, { id: statusId });
|
||||
ancestorsIds = ancestorsIds.delete(statusId).subtract(descendantsIds);
|
||||
descendantsIds = descendantsIds.delete(statusId).subtract(ancestorsIds);
|
||||
}
|
||||
|
||||
const soapbox = getSoapboxConfig(state);
|
||||
|
|
Ładowanie…
Reference in New Issue