From fbee7a237c1f6c2b2d21e601812356604218a4a9 Mon Sep 17 00:00:00 2001 From: Mary Kate Date: Tue, 25 Aug 2020 14:48:41 -0500 Subject: [PATCH 1/3] pass last statusID into status list before filtering, fixes #340 --- app/soapbox/components/status_list.js | 4 +++- app/soapbox/features/ui/containers/status_list_container.js | 4 ++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/app/soapbox/components/status_list.js b/app/soapbox/components/status_list.js index a21884810..be523eafd 100644 --- a/app/soapbox/components/status_list.js +++ b/app/soapbox/components/status_list.js @@ -18,6 +18,7 @@ export default class StatusList extends ImmutablePureComponent { static propTypes = { scrollKey: PropTypes.string.isRequired, statusIds: ImmutablePropTypes.list.isRequired, + lastStatusId: PropTypes.string, featuredStatusIds: ImmutablePropTypes.list, onLoadMore: PropTypes.func, isLoading: PropTypes.bool, @@ -62,7 +63,8 @@ export default class StatusList extends ImmutablePureComponent { } handleLoadOlder = debounce(() => { - this.props.onLoadMore(this.props.statusIds.size > 0 ? this.props.statusIds.last() : undefined); + const loadMoreID = this.props.lastStatusId ? this.props.lastStatusId : this.props.statusIds.last(); + this.props.onLoadMore(loadMoreID ? loadMoreID : undefined); }, 300, { leading: true }) _selectChild(index, align_top) { diff --git a/app/soapbox/features/ui/containers/status_list_container.js b/app/soapbox/features/ui/containers/status_list_container.js index 03afa4b88..5087c4f7a 100644 --- a/app/soapbox/features/ui/containers/status_list_container.js +++ b/app/soapbox/features/ui/containers/status_list_container.js @@ -8,12 +8,15 @@ import { scrollTopTimeline } from '../../../actions/timelines'; import { getSettings } from 'soapbox/actions/settings'; import { shouldFilter } from 'soapbox/utils/timelines'; +let lastStatusId; + const makeGetStatusIds = () => createSelector([ (state, { type }) => getSettings(state).get(type, ImmutableMap()), (state, { type }) => state.getIn(['timelines', type, 'items'], ImmutableList()), (state) => state.get('statuses'), (state) => state.get('me'), ], (columnSettings, statusIds, statuses, me) => { + lastStatusId = statusIds.last(); return statusIds.filter(id => { const status = statuses.get(id); if (!status) return true; @@ -26,6 +29,7 @@ const mapStateToProps = (state, { timelineId }) => { return { statusIds: getStatusIds(state, { type: timelineId }), + lastStatusId: lastStatusId, isLoading: state.getIn(['timelines', timelineId, 'isLoading'], true), isPartial: state.getIn(['timelines', timelineId, 'isPartial'], false), hasMore: state.getIn(['timelines', timelineId, 'hasMore']), From 82c590d74bfb74a106cf2a891cc3eb7aa3b87d01 Mon Sep 17 00:00:00 2001 From: Mary Kate Date: Wed, 26 Aug 2020 11:42:20 -0500 Subject: [PATCH 2/3] simplify onLoadMore in status list --- app/soapbox/components/status_list.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/soapbox/components/status_list.js b/app/soapbox/components/status_list.js index be523eafd..97c5a11d7 100644 --- a/app/soapbox/components/status_list.js +++ b/app/soapbox/components/status_list.js @@ -64,7 +64,7 @@ export default class StatusList extends ImmutablePureComponent { handleLoadOlder = debounce(() => { const loadMoreID = this.props.lastStatusId ? this.props.lastStatusId : this.props.statusIds.last(); - this.props.onLoadMore(loadMoreID ? loadMoreID : undefined); + this.props.onLoadMore(loadMoreID); }, 300, { leading: true }) _selectChild(index, align_top) { From 5c03f855f6b74b9fe5278eb122785a4dea4709f4 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Wed, 26 Aug 2020 14:31:22 -0500 Subject: [PATCH 3/3] lastStatusId: move assignment out of selector --- app/soapbox/features/ui/containers/status_list_container.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/app/soapbox/features/ui/containers/status_list_container.js b/app/soapbox/features/ui/containers/status_list_container.js index 5087c4f7a..41c345df3 100644 --- a/app/soapbox/features/ui/containers/status_list_container.js +++ b/app/soapbox/features/ui/containers/status_list_container.js @@ -8,15 +8,12 @@ import { scrollTopTimeline } from '../../../actions/timelines'; import { getSettings } from 'soapbox/actions/settings'; import { shouldFilter } from 'soapbox/utils/timelines'; -let lastStatusId; - const makeGetStatusIds = () => createSelector([ (state, { type }) => getSettings(state).get(type, ImmutableMap()), (state, { type }) => state.getIn(['timelines', type, 'items'], ImmutableList()), (state) => state.get('statuses'), (state) => state.get('me'), ], (columnSettings, statusIds, statuses, me) => { - lastStatusId = statusIds.last(); return statusIds.filter(id => { const status = statuses.get(id); if (!status) return true; @@ -25,6 +22,7 @@ const makeGetStatusIds = () => createSelector([ }); const mapStateToProps = (state, { timelineId }) => { + const lastStatusId = state.getIn(['timelines', timelineId, 'items'], ImmutableList()).last(); const getStatusIds = makeGetStatusIds(); return {