mirror of
https://git.bsd.gay/fef/nyastodon.git
synced 2024-12-26 06:43:42 +01:00
[Glitch] Fix explore prompt appearing because of posts being received out of order
Port d80a819fc6
to glitch-soc
Signed-off-by: Claire <claire.github-309c@sitedethib.com>
This commit is contained in:
parent
e9a181c52c
commit
e83059fd9d
1 changed files with 11 additions and 2 deletions
|
@ -39,8 +39,17 @@ const getHomeFeedSpeed = createSelector([
|
||||||
], (statusIds, pendingStatusIds, statusMap) => {
|
], (statusIds, pendingStatusIds, statusMap) => {
|
||||||
const recentStatusIds = pendingStatusIds.size > 0 ? pendingStatusIds : statusIds;
|
const recentStatusIds = pendingStatusIds.size > 0 ? pendingStatusIds : statusIds;
|
||||||
const statuses = recentStatusIds.filter(id => id !== null).map(id => statusMap.get(id)).filter(status => status?.get('account') !== me).take(20);
|
const statuses = recentStatusIds.filter(id => id !== null).map(id => statusMap.get(id)).filter(status => status?.get('account') !== me).take(20);
|
||||||
const oldest = new Date(statuses.getIn([statuses.size - 1, 'created_at'], 0));
|
|
||||||
const newest = new Date(statuses.getIn([0, 'created_at'], 0));
|
if (statuses.isEmpty()) {
|
||||||
|
return {
|
||||||
|
gap: 0,
|
||||||
|
newest: new Date(0),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
const datetimes = statuses.map(status => status.get('created_at', 0));
|
||||||
|
const oldest = new Date(datetimes.min());
|
||||||
|
const newest = new Date(datetimes.max());
|
||||||
const averageGap = (newest - oldest) / (1000 * (statuses.size + 1)); // Average gap between posts on first page in seconds
|
const averageGap = (newest - oldest) / (1000 * (statuses.size + 1)); // Average gap between posts on first page in seconds
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|
Loading…
Reference in a new issue