Use OrderedSet

Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
merge-requests/656/head
marcin mikołajczak 3 years ago
parent b01b175fdc
commit 0877574c28

@ -71,15 +71,13 @@ const makeMapStateToProps = () => {
(_, { id }) => id,
state => state.getIn(['contexts', 'inReplyTos']),
], (statusId, inReplyTos) => {
let ancestorsIds = Immutable.List();
ancestorsIds = ancestorsIds.withMutations(mutable => {
let ancestorsIds = Immutable.OrderedSet();
let id = statusId;
while (id) {
mutable.unshift(id);
ancestorsIds = Immutable.OrderedSet([id]).union(ancestorsIds);
id = inReplyTos.get(id);
}
});
return ancestorsIds;
});
@ -88,8 +86,7 @@ const makeMapStateToProps = () => {
(_, { id }) => id,
state => state.getIn(['contexts', 'replies']),
], (statusId, contextReplies) => {
let descendantsIds = Immutable.List();
descendantsIds = descendantsIds.withMutations(mutable => {
let descendantsIds = Immutable.OrderedSet();
const ids = [statusId];
while (ids.length > 0) {
@ -97,7 +94,7 @@ const makeMapStateToProps = () => {
const replies = contextReplies.get(id);
if (statusId !== id) {
mutable.push(id);
descendantsIds = descendantsIds.union([id]);
}
if (replies) {
@ -106,7 +103,6 @@ const makeMapStateToProps = () => {
});
}
}
});
return descendantsIds;
});

Loading…
Cancel
Save