* Revert "persist last-intersected status update and restore when ScrollableList is restored" This reverts commit 07e26142ef6a8e74bd2ac5e9b461a5a1699bd4c8. accidentally merged spurious code in https://github.com/tootsuite/mastodon/pull/12661. https://github.com/tootsuite/mastodon/pull/12735 removes the slowdown that this code was trying to solve; and other functionality successfully restores the view state of the list * Revert "cache currently-viewing status id to avoid calling redux with identical value" This reverts commit c93df2159fbd3888a5c48d8a8b8ae61dbbc54b89. accidentally merged spurious code in https://github.com/tootsuite/mastodon/pull/12661. https://github.com/tootsuite/mastodon/pull/12735 removes the slowdown that this code was trying to solve; and other functionality successfully restores the view state of the list
62 lines
2.1 KiB
JavaScript
62 lines
2.1 KiB
JavaScript
import { connect } from 'react-redux';
|
|
import StatusList from '../../../components/status_list';
|
|
import { scrollTopTimeline, loadPending } from '../../../actions/timelines';
|
|
import { Map as ImmutableMap, List as ImmutableList } from 'immutable';
|
|
import { createSelector } from 'reselect';
|
|
import { debounce } from 'lodash';
|
|
import { me } from '../../../initial_state';
|
|
|
|
const makeGetStatusIds = (pending = false) => createSelector([
|
|
(state, { type }) => state.getIn(['settings', type], ImmutableMap()),
|
|
(state, { type }) => state.getIn(['timelines', type, pending ? 'pendingItems' : 'items'], ImmutableList()),
|
|
(state) => state.get('statuses'),
|
|
], (columnSettings, statusIds, statuses) => {
|
|
return statusIds.filter(id => {
|
|
if (id === null) return true;
|
|
|
|
const statusForId = statuses.get(id);
|
|
let showStatus = true;
|
|
|
|
if (columnSettings.getIn(['shows', 'reblog']) === false) {
|
|
showStatus = showStatus && statusForId.get('reblog') === null;
|
|
}
|
|
|
|
if (columnSettings.getIn(['shows', 'reply']) === false) {
|
|
showStatus = showStatus && (statusForId.get('in_reply_to_id') === null || statusForId.get('in_reply_to_account_id') === me);
|
|
}
|
|
|
|
return showStatus;
|
|
});
|
|
});
|
|
|
|
const makeMapStateToProps = () => {
|
|
const getStatusIds = makeGetStatusIds();
|
|
const getPendingStatusIds = makeGetStatusIds(true);
|
|
|
|
const mapStateToProps = (state, { timelineId }) => ({
|
|
statusIds: getStatusIds(state, { type: timelineId }),
|
|
isLoading: state.getIn(['timelines', timelineId, 'isLoading'], true),
|
|
isPartial: state.getIn(['timelines', timelineId, 'isPartial'], false),
|
|
hasMore: state.getIn(['timelines', timelineId, 'hasMore']),
|
|
numPending: getPendingStatusIds(state, { type: timelineId }).size,
|
|
});
|
|
|
|
return mapStateToProps;
|
|
};
|
|
|
|
const mapDispatchToProps = (dispatch, { timelineId }) => ({
|
|
|
|
onScrollToTop: debounce(() => {
|
|
dispatch(scrollTopTimeline(timelineId, true));
|
|
}, 100),
|
|
|
|
onScroll: debounce(() => {
|
|
dispatch(scrollTopTimeline(timelineId, false));
|
|
}, 100),
|
|
|
|
onLoadPending: () => dispatch(loadPending(timelineId)),
|
|
|
|
});
|
|
|
|
export default connect(makeMapStateToProps, mapDispatchToProps)(StatusList);
|