[Glitch] Remove unique accounts condition from Home onboarding prompt
Port 0842a68532
to glitch-soc
Signed-off-by: Claire <claire.github-309c@sitedethib.com>
pull/62/head
parent
6fb34258a4
commit
5def74a436
|
@ -11,19 +11,20 @@ import { connect } from 'react-redux';
|
||||||
import { createSelector } from 'reselect';
|
import { createSelector } from 'reselect';
|
||||||
|
|
||||||
import { fetchAnnouncements, toggleShowAnnouncements } from 'flavours/glitch/actions/announcements';
|
import { fetchAnnouncements, toggleShowAnnouncements } from 'flavours/glitch/actions/announcements';
|
||||||
import { addColumn, removeColumn, moveColumn } from 'flavours/glitch/actions/columns';
|
|
||||||
import { expandHomeTimeline } from 'flavours/glitch/actions/timelines';
|
|
||||||
import Column from 'flavours/glitch/components/column';
|
|
||||||
import ColumnHeader from 'flavours/glitch/components/column_header';
|
|
||||||
import { IconWithBadge } from 'flavours/glitch/components/icon_with_badge';
|
import { IconWithBadge } from 'flavours/glitch/components/icon_with_badge';
|
||||||
import { NotSignedInIndicator } from 'flavours/glitch/components/not_signed_in_indicator';
|
import { NotSignedInIndicator } from 'flavours/glitch/components/not_signed_in_indicator';
|
||||||
import AnnouncementsContainer from 'flavours/glitch/features/getting_started/containers/announcements_container';
|
import AnnouncementsContainer from 'flavours/glitch/features/getting_started/containers/announcements_container';
|
||||||
import StatusListContainer from 'flavours/glitch/features/ui/containers/status_list_container';
|
import { me } from 'flavours/glitch/initial_state';
|
||||||
|
|
||||||
|
import { addColumn, removeColumn, moveColumn } from '../../actions/columns';
|
||||||
|
import { expandHomeTimeline } from '../../actions/timelines';
|
||||||
|
import Column from '../../components/column';
|
||||||
|
import ColumnHeader from '../../components/column_header';
|
||||||
|
import StatusListContainer from '../ui/containers/status_list_container';
|
||||||
|
|
||||||
import { ExplorePrompt } from './components/explore_prompt';
|
import { ExplorePrompt } from './components/explore_prompt';
|
||||||
import ColumnSettingsContainer from './containers/column_settings_container';
|
import ColumnSettingsContainer from './containers/column_settings_container';
|
||||||
|
|
||||||
|
|
||||||
const messages = defineMessages({
|
const messages = defineMessages({
|
||||||
title: { id: 'column.home', defaultMessage: 'Home' },
|
title: { id: 'column.home', defaultMessage: 'Home' },
|
||||||
show_announcements: { id: 'home.show_announcements', defaultMessage: 'Show announcements' },
|
show_announcements: { id: 'home.show_announcements', defaultMessage: 'Show announcements' },
|
||||||
|
@ -34,22 +35,19 @@ const getHomeFeedSpeed = createSelector([
|
||||||
state => state.getIn(['timelines', 'home', 'items'], ImmutableList()),
|
state => state.getIn(['timelines', 'home', 'items'], ImmutableList()),
|
||||||
state => state.get('statuses'),
|
state => state.get('statuses'),
|
||||||
], (statusIds, statusMap) => {
|
], (statusIds, statusMap) => {
|
||||||
const statuses = statusIds.take(20).map(id => statusMap.get(id));
|
const statuses = statusIds.map(id => statusMap.get(id)).filter(status => status.get('account') !== me).take(20);
|
||||||
const uniqueAccountIds = (new Set(statuses.map(status => status.get('account')).toArray())).size;
|
|
||||||
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
|
||||||
|
|
||||||
return {
|
return {
|
||||||
unique: uniqueAccountIds,
|
|
||||||
gap: averageGap,
|
gap: averageGap,
|
||||||
newest,
|
newest,
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
const homeTooSlow = createSelector(getHomeFeedSpeed, speed =>
|
const homeTooSlow = createSelector(getHomeFeedSpeed, speed =>
|
||||||
speed.unique < 5 // If there are fewer than 5 different accounts visible
|
speed.gap > (30 * 60) // If the average gap between posts is more than 20 minutes
|
||||||
|| 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
|
|| (Date.now() - speed.newest) > (1000 * 3600) // If the most recent post is from over an hour ago
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue