summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorClaire <claire.github-309c@sitedethib.com>2023-09-29 15:51:36 +0200
committerGitHub <noreply@github.com>2023-09-29 15:51:36 +0200
commitd80a819fc60b530042784cc3f20cd3041ee0a996 (patch)
tree0fe0f6da1bc92176abce182754bf7f33a0d2874d
parent5393be7a21331c8615ffb79c2271db92f6959458 (diff)
Fix explore prompt appearing because of posts being received out of order (#27211)
-rw-r--r--app/javascript/mastodon/features/home_timeline/index.jsx13
1 files changed, 11 insertions, 2 deletions
diff --git a/app/javascript/mastodon/features/home_timeline/index.jsx b/app/javascript/mastodon/features/home_timeline/index.jsx
index 63d373b9a96..93f9376285e 100644
--- a/app/javascript/mastodon/features/home_timeline/index.jsx
+++ b/app/javascript/mastodon/features/home_timeline/index.jsx
@@ -39,8 +39,17 @@ const getHomeFeedSpeed = createSelector([
], (statusIds, pendingStatusIds, statusMap) => {
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 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
return {