lastStatusId: move assignment out of selector

This commit is contained in:
Alex Gleason 2020-08-26 14:31:22 -05:00
parent 82c590d74b
commit 5c03f855f6
No known key found for this signature in database
GPG key ID: 7211D1F99744FBB7

View file

@ -8,15 +8,12 @@ import { scrollTopTimeline } from '../../../actions/timelines';
import { getSettings } from 'soapbox/actions/settings'; import { getSettings } from 'soapbox/actions/settings';
import { shouldFilter } from 'soapbox/utils/timelines'; import { shouldFilter } from 'soapbox/utils/timelines';
let lastStatusId;
const makeGetStatusIds = () => createSelector([ const makeGetStatusIds = () => createSelector([
(state, { type }) => getSettings(state).get(type, ImmutableMap()), (state, { type }) => getSettings(state).get(type, ImmutableMap()),
(state, { type }) => state.getIn(['timelines', type, 'items'], ImmutableList()), (state, { type }) => state.getIn(['timelines', type, 'items'], ImmutableList()),
(state) => state.get('statuses'), (state) => state.get('statuses'),
(state) => state.get('me'), (state) => state.get('me'),
], (columnSettings, statusIds, statuses, me) => { ], (columnSettings, statusIds, statuses, me) => {
lastStatusId = statusIds.last();
return statusIds.filter(id => { return statusIds.filter(id => {
const status = statuses.get(id); const status = statuses.get(id);
if (!status) return true; if (!status) return true;
@ -25,6 +22,7 @@ const makeGetStatusIds = () => createSelector([
}); });
const mapStateToProps = (state, { timelineId }) => { const mapStateToProps = (state, { timelineId }) => {
const lastStatusId = state.getIn(['timelines', timelineId, 'items'], ImmutableList()).last();
const getStatusIds = makeGetStatusIds(); const getStatusIds = makeGetStatusIds();
return { return {