promotion fe

This commit is contained in:
2458773093
2019-08-31 14:54:03 +03:00
parent 0499184b38
commit 168642a1b9
4 changed files with 53 additions and 14 deletions

View File

@@ -3,9 +3,11 @@ import StatusList from '../../../components/status_list';
import { Map as ImmutableMap, List as ImmutableList } from 'immutable';
import { createSelector } from 'reselect';
import { debounce } from 'lodash';
import { me } from '../../../initial_state';
import { me, promotions } from '../../../initial_state';
import { dequeueTimeline } from 'gabsocial/actions/timelines';
import { scrollTopTimeline } from '../../../actions/timelines';
import { sample } from 'lodash';
import { fetchStatus } from '../../../actions/statuses';
const makeGetStatusIds = () => createSelector([
(state, { type, id }) => state.getIn(['settings', type], ImmutableMap()),
@@ -32,6 +34,7 @@ const makeGetStatusIds = () => createSelector([
const mapStateToProps = (state, {timelineId}) => {
const getStatusIds = makeGetStatusIds();
const promotion = promotions.length > 0 && sample(promotions.filter(p => p.timeline_id === timelineId));
return {
statusIds: getStatusIds(state, { type: timelineId.substring(0,5) === 'group' ? 'group' : timelineId, id: timelineId }),
@@ -39,6 +42,8 @@ const mapStateToProps = (state, {timelineId}) => {
isPartial: state.getIn(['timelines', timelineId, 'isPartial'], false),
hasMore: state.getIn(['timelines', timelineId, 'hasMore']),
totalQueuedItemsCount: state.getIn(['timelines', timelineId, 'totalQueuedItemsCount']),
promotion: promotion,
promotedStatus: promotion && state.getIn(['statuses', promotion.status_id])
};
};
@@ -52,6 +57,9 @@ const mapDispatchToProps = (dispatch, ownProps) => ({
onScroll: debounce(() => {
dispatch(scrollTopTimeline(ownProps.timelineId, false));
}, 100),
fetchStatus(id) {
dispatch(fetchStatus(id));
}
});
export default connect(mapStateToProps, mapDispatchToProps)(StatusList);