The code powering m.abunchtell.com https://m.abunchtell.com
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.
 
 
 
 

57 rindas
1.8 KiB

  1. import { connect } from 'react-redux';
  2. import StatusList from '../../../components/status_list';
  3. import { expandTimeline, scrollTopTimeline } from '../../../actions/timelines';
  4. import Immutable from 'immutable';
  5. import { createSelector } from 'reselect';
  6. const getStatusIds = createSelector([
  7. (state, { type }) => state.getIn(['settings', type]),
  8. (state, { type }) => state.getIn(['timelines', type, 'items'], Immutable.List()),
  9. (state) => state.get('statuses')
  10. ], (columnSettings, statusIds, statuses) => statusIds.filter(id => {
  11. const statusForId = statuses.get(id);
  12. let showStatus = true;
  13. if (columnSettings.getIn(['shows', 'reblog']) === false) {
  14. showStatus = showStatus && statusForId.get('reblog') === null;
  15. }
  16. if (columnSettings.getIn(['shows', 'reply']) === false) {
  17. showStatus = showStatus && statusForId.get('in_reply_to_id') === null;
  18. }
  19. if (columnSettings.getIn(['regex', 'body'], '').trim().length > 0) {
  20. try {
  21. const regex = new RegExp(columnSettings.getIn(['regex', 'body']).trim(), 'i');
  22. showStatus = showStatus && !regex.test(statusForId.get('reblog') ? statuses.getIn([statusForId.get('reblog'), 'content']) : statusForId.get('content'));
  23. } catch(e) {
  24. // Bad regex, don't affect filters
  25. }
  26. }
  27. return showStatus;
  28. }));
  29. const mapStateToProps = (state, props) => ({
  30. statusIds: getStatusIds(state, props)
  31. });
  32. const mapDispatchToProps = (dispatch, { type, id }) => ({
  33. onScrollToBottom () {
  34. dispatch(scrollTopTimeline(type, false));
  35. dispatch(expandTimeline(type, id));
  36. },
  37. onScrollToTop () {
  38. dispatch(scrollTopTimeline(type, true));
  39. },
  40. onScroll () {
  41. dispatch(scrollTopTimeline(type, false));
  42. }
  43. });
  44. export default connect(mapStateToProps, mapDispatchToProps)(StatusList);