mirror of
https://github.com/mastodon/mastodon.git
synced 2024-12-23 17:44:24 +00:00
Fix onboarding prompt flashing while home feed is loading in web UI (#25579)
This commit is contained in:
parent
2b78c07ef1
commit
65aa04647a
|
@ -33,9 +33,11 @@ const messages = defineMessages({
|
||||||
|
|
||||||
const getHomeFeedSpeed = createSelector([
|
const getHomeFeedSpeed = createSelector([
|
||||||
state => state.getIn(['timelines', 'home', 'items'], ImmutableList()),
|
state => state.getIn(['timelines', 'home', 'items'], ImmutableList()),
|
||||||
|
state => state.getIn(['timelines', 'home', 'pendingItems'], ImmutableList()),
|
||||||
state => state.get('statuses'),
|
state => state.get('statuses'),
|
||||||
], (statusIds, statusMap) => {
|
], (statusIds, pendingStatusIds, statusMap) => {
|
||||||
const statuses = statusIds.map(id => statusMap.get(id)).filter(status => status.get('account') !== me).take(20);
|
const recentStatusIds = pendingStatusIds.size > 0 ? pendingStatusIds : statusIds;
|
||||||
|
const statuses = recentStatusIds.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 oldest = new Date(statuses.getIn([statuses.size - 1, 'created_at'], 0));
|
||||||
const newest = new Date(statuses.getIn([0, 'created_at'], 0));
|
const newest = new Date(statuses.getIn([0, 'created_at'], 0));
|
||||||
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
|
||||||
|
@ -46,9 +48,14 @@ const getHomeFeedSpeed = createSelector([
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
const homeTooSlow = createSelector(getHomeFeedSpeed, speed =>
|
const homeTooSlow = createSelector([
|
||||||
speed.gap > (30 * 60) // If the average gap between posts is more than 20 minutes
|
state => state.getIn(['timelines', 'home', 'isLoading']),
|
||||||
|| (Date.now() - speed.newest) > (1000 * 3600) // If the most recent post is from over an hour ago
|
state => state.getIn(['timelines', 'home', 'isPartial']),
|
||||||
|
getHomeFeedSpeed,
|
||||||
|
], (isLoading, isPartial, speed) =>
|
||||||
|
!isLoading && !isPartial // Only if the home feed has finished loading
|
||||||
|
&& (speed.gap > (30 * 60) // If the average gap between posts is more than 20 minutes
|
||||||
|
|| (Date.now() - speed.newest) > (1000 * 3600)) // If the most recent post is from over an hour ago
|
||||||
);
|
);
|
||||||
|
|
||||||
const mapStateToProps = state => ({
|
const mapStateToProps = state => ({
|
||||||
|
|
Loading…
Reference in a new issue