Fix posts appearing repeatedly in the timeline
This commit is contained in:
parent
bd183630a4
commit
dde6c4f845
2 changed files with 13 additions and 3 deletions
|
@ -20,6 +20,8 @@ import {
|
|||
} from '../actions/accounts';
|
||||
import { Map as ImmutableMap, List as ImmutableList, fromJS } from 'immutable';
|
||||
import compareId from '../compare_id';
|
||||
import { uniqWithoutNull } from '../utils/uniq';
|
||||
|
||||
|
||||
const initialState = ImmutableMap();
|
||||
|
||||
|
@ -52,13 +54,13 @@ const expandNormalizedTimeline = (state, timeline, statuses, next, isPartial, is
|
|||
const firstIndex = oldIds.take(lastIndex).findLastIndex(id => id !== null && compareId(id, newIds.first()) > 0);
|
||||
|
||||
if (firstIndex < 0) {
|
||||
return (isPartial ? newIds.unshift(null) : newIds).concat(oldIds.skip(lastIndex));
|
||||
return uniqWithoutNull(isPartial ? newIds.unshift(null) : newIds).concat(oldIds.skip(lastIndex));
|
||||
}
|
||||
|
||||
return oldIds.take(firstIndex + 1).concat(
|
||||
return uniqWithoutNull(oldIds.take(firstIndex + 1).concat(
|
||||
isPartial && oldIds.get(firstIndex) !== null ? newIds.unshift(null) : newIds,
|
||||
oldIds.skip(lastIndex),
|
||||
);
|
||||
));
|
||||
});
|
||||
}
|
||||
}));
|
||||
|
|
|
@ -1,3 +1,11 @@
|
|||
export const uniq = array => {
|
||||
return array.filter((x, i, self) => self.indexOf(x) === i)
|
||||
};
|
||||
|
||||
export const uniqCompact = array => {
|
||||
return array.filter((x, i, self) => x && self.indexOf(x) === i)
|
||||
};
|
||||
|
||||
export const uniqWithoutNull = array => {
|
||||
return array.filter((x, i, self) => !x || self.indexOf(x) === i)
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue