|
@@ -6,8 +6,6 @@ import { defineMessages, injectIntl, FormattedMessage } from 'react-intl';
|
|
import classNames from 'classnames';
|
|
import classNames from 'classnames';
|
|
import { Helmet } from 'react-helmet';
|
|
import { Helmet } from 'react-helmet';
|
|
|
|
|
|
-import { createSelector } from '@reduxjs/toolkit';
|
|
|
|
-import { List as ImmutableList } from 'immutable';
|
|
|
|
import { connect } from 'react-redux';
|
|
import { connect } from 'react-redux';
|
|
|
|
|
|
import CampaignIcon from '@/material-icons/400-24px/campaign.svg?react';
|
|
import CampaignIcon from '@/material-icons/400-24px/campaign.svg?react';
|
|
@@ -16,7 +14,7 @@ import { fetchAnnouncements, toggleShowAnnouncements } from 'mastodon/actions/an
|
|
import { IconWithBadge } from 'mastodon/components/icon_with_badge';
|
|
import { IconWithBadge } from 'mastodon/components/icon_with_badge';
|
|
import { NotSignedInIndicator } from 'mastodon/components/not_signed_in_indicator';
|
|
import { NotSignedInIndicator } from 'mastodon/components/not_signed_in_indicator';
|
|
import AnnouncementsContainer from 'mastodon/features/getting_started/containers/announcements_container';
|
|
import AnnouncementsContainer from 'mastodon/features/getting_started/containers/announcements_container';
|
|
-import { me, criticalUpdatesPending } from 'mastodon/initial_state';
|
|
|
|
|
|
+import { criticalUpdatesPending } from 'mastodon/initial_state';
|
|
|
|
|
|
import { addColumn, removeColumn, moveColumn } from '../../actions/columns';
|
|
import { addColumn, removeColumn, moveColumn } from '../../actions/columns';
|
|
import { expandHomeTimeline } from '../../actions/timelines';
|
|
import { expandHomeTimeline } from '../../actions/timelines';
|
|
@@ -26,7 +24,6 @@ import StatusListContainer from '../ui/containers/status_list_container';
|
|
|
|
|
|
import { ColumnSettings } from './components/column_settings';
|
|
import { ColumnSettings } from './components/column_settings';
|
|
import { CriticalUpdateBanner } from './components/critical_update_banner';
|
|
import { CriticalUpdateBanner } from './components/critical_update_banner';
|
|
-import { ExplorePrompt } from './components/explore_prompt';
|
|
|
|
|
|
|
|
const messages = defineMessages({
|
|
const messages = defineMessages({
|
|
title: { id: 'column.home', defaultMessage: 'Home' },
|
|
title: { id: 'column.home', defaultMessage: 'Home' },
|
|
@@ -34,51 +31,12 @@ const messages = defineMessages({
|
|
hide_announcements: { id: 'home.hide_announcements', defaultMessage: 'Hide announcements' },
|
|
hide_announcements: { id: 'home.hide_announcements', defaultMessage: 'Hide announcements' },
|
|
});
|
|
});
|
|
|
|
|
|
-const getHomeFeedSpeed = createSelector([
|
|
|
|
- state => state.getIn(['timelines', 'home', 'items'], ImmutableList()),
|
|
|
|
- state => state.getIn(['timelines', 'home', 'pendingItems'], ImmutableList()),
|
|
|
|
- state => state.get('statuses'),
|
|
|
|
-], (statusIds, pendingStatusIds, statusMap) => {
|
|
|
|
- const recentStatusIds = pendingStatusIds.concat(statusIds);
|
|
|
|
- const statuses = recentStatusIds.filter(id => id !== null).map(id => statusMap.get(id)).filter(status => status?.get('account') !== me).take(20);
|
|
|
|
-
|
|
|
|
- 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 {
|
|
|
|
- gap: averageGap,
|
|
|
|
- newest,
|
|
|
|
- };
|
|
|
|
-});
|
|
|
|
-
|
|
|
|
-const homeTooSlow = createSelector([
|
|
|
|
- state => state.getIn(['timelines', 'home', 'isLoading']),
|
|
|
|
- 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 30 minutes
|
|
|
|
- || (Date.now() - speed.newest) > (1000 * 3600)) // If the most recent post is from over an hour ago
|
|
|
|
- )
|
|
|
|
-);
|
|
|
|
-
|
|
|
|
const mapStateToProps = state => ({
|
|
const mapStateToProps = state => ({
|
|
hasUnread: state.getIn(['timelines', 'home', 'unread']) > 0,
|
|
hasUnread: state.getIn(['timelines', 'home', 'unread']) > 0,
|
|
isPartial: state.getIn(['timelines', 'home', 'isPartial']),
|
|
isPartial: state.getIn(['timelines', 'home', 'isPartial']),
|
|
hasAnnouncements: !state.getIn(['announcements', 'items']).isEmpty(),
|
|
hasAnnouncements: !state.getIn(['announcements', 'items']).isEmpty(),
|
|
unreadAnnouncements: state.getIn(['announcements', 'items']).count(item => !item.get('read')),
|
|
unreadAnnouncements: state.getIn(['announcements', 'items']).count(item => !item.get('read')),
|
|
showAnnouncements: state.getIn(['announcements', 'show']),
|
|
showAnnouncements: state.getIn(['announcements', 'show']),
|
|
- tooSlow: homeTooSlow(state),
|
|
|
|
});
|
|
});
|
|
|
|
|
|
class HomeTimeline extends PureComponent {
|
|
class HomeTimeline extends PureComponent {
|
|
@@ -97,7 +55,6 @@ class HomeTimeline extends PureComponent {
|
|
hasAnnouncements: PropTypes.bool,
|
|
hasAnnouncements: PropTypes.bool,
|
|
unreadAnnouncements: PropTypes.number,
|
|
unreadAnnouncements: PropTypes.number,
|
|
showAnnouncements: PropTypes.bool,
|
|
showAnnouncements: PropTypes.bool,
|
|
- tooSlow: PropTypes.bool,
|
|
|
|
};
|
|
};
|
|
|
|
|
|
handlePin = () => {
|
|
handlePin = () => {
|
|
@@ -167,7 +124,7 @@ class HomeTimeline extends PureComponent {
|
|
};
|
|
};
|
|
|
|
|
|
render () {
|
|
render () {
|
|
- const { intl, hasUnread, columnId, multiColumn, tooSlow, hasAnnouncements, unreadAnnouncements, showAnnouncements } = this.props;
|
|
|
|
|
|
+ const { intl, hasUnread, columnId, multiColumn, hasAnnouncements, unreadAnnouncements, showAnnouncements } = this.props;
|
|
const pinned = !!columnId;
|
|
const pinned = !!columnId;
|
|
const { signedIn } = this.context.identity;
|
|
const { signedIn } = this.context.identity;
|
|
const banners = [];
|
|
const banners = [];
|
|
@@ -192,10 +149,6 @@ class HomeTimeline extends PureComponent {
|
|
banners.push(<CriticalUpdateBanner key='critical-update-banner' />);
|
|
banners.push(<CriticalUpdateBanner key='critical-update-banner' />);
|
|
}
|
|
}
|
|
|
|
|
|
- if (tooSlow) {
|
|
|
|
- banners.push(<ExplorePrompt key='explore-prompt' />);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
return (
|
|
return (
|
|
<Column bindToDocument={!multiColumn} ref={this.setRef} label={intl.formatMessage(messages.title)}>
|
|
<Column bindToDocument={!multiColumn} ref={this.setRef} label={intl.formatMessage(messages.title)}>
|
|
<ColumnHeader
|
|
<ColumnHeader
|