export const TIMELINE_DISCONNECT = 'TIMELINE_DISCONNECT';
export const TIMELINE_CONNECT = 'TIMELINE_CONNECT';
-export const CURRENTLY_VIEWING = 'CURRENTLY_VIEWING';
-
-export const updateCurrentlyViewing = (timeline, id) => ({
- type: CURRENTLY_VIEWING,
- timeline,
- id,
-});
-
export const loadPending = timeline => ({
type: TIMELINE_LOAD_PENDING,
timeline,
cachedHeight: PropTypes.number,
onHeightChange: PropTypes.func,
children: PropTypes.node,
- currentlyViewing: PropTypes.number,
- updateCurrentlyViewing: PropTypes.func,
};
state = {
);
this.componentMounted = true;
-
- if(id === this.props.currentlyViewing) this.node.scrollIntoView();
}
componentWillUnmount () {
handleIntersection = (entry) => {
this.entry = entry;
- if(entry.intersectionRatio > 0.75 && this.props.updateCurrentlyViewing) this.props.updateCurrentlyViewing(this.id);
-
scheduleIdleTask(this.calculateHeight);
this.setState(this.updateStateAfterIntersection);
}
emptyMessage: PropTypes.node,
children: PropTypes.node,
bindToDocument: PropTypes.bool,
- currentlyViewing: PropTypes.number,
- updateCurrentlyViewing: PropTypes.func,
};
static defaultProps = {
listLength={childrenCount}
intersectionObserverWrapper={this.intersectionObserverWrapper}
saveHeightKey={trackScroll ? `${this.context.router.route.location.key}:${scrollKey}` : null}
- currentlyViewing={this.props.currentlyViewing}
- updateCurrentlyViewing={this.props.updateCurrentlyViewing}
>
{React.cloneElement(child, {
getScrollPosition: this.getScrollPosition,
emptyMessage: PropTypes.node,
alwaysPrepend: PropTypes.bool,
timelineId: PropTypes.string,
- currentlyViewing: PropTypes.number,
- updateCurrentlyViewing: PropTypes.func,
};
static defaultProps = {
this.props.onLoadMore(this.props.statusIds.size > 0 ? this.props.statusIds.last() : undefined);
}, 300, { leading: true })
- updateCurrentlyViewingWithCache = (id) => {
- if(this.cachedCurrentlyViewing === id) return;
- this.cachedCurrentlyViewing = id;
- this.props.updateCurrentlyViewing(id);
- }
-
_selectChild (index, align_top) {
const container = this.node.node;
const element = container.querySelector(`article:nth-of-type(${index + 1}) .focusable`);
render () {
const { statusIds, featuredStatusIds, shouldUpdateScroll, onLoadMore, timelineId, ...other } = this.props;
const { isLoading, isPartial } = other;
- other.updateCurrentlyViewing = this.updateCurrentlyViewingWithCache;
if (isPartial) {
return <RegenerationIndicator />;
import { connect } from 'react-redux';
import StatusList from '../../../components/status_list';
-import { scrollTopTimeline, loadPending, updateCurrentlyViewing } from '../../../actions/timelines';
+import { scrollTopTimeline, loadPending } from '../../../actions/timelines';
import { Map as ImmutableMap, List as ImmutableList } from 'immutable';
import { createSelector } from 'reselect';
import { debounce } from 'lodash';
isPartial: state.getIn(['timelines', timelineId, 'isPartial'], false),
hasMore: state.getIn(['timelines', timelineId, 'hasMore']),
numPending: getPendingStatusIds(state, { type: timelineId }).size,
- currentlyViewing: state.getIn(['timelines', timelineId, 'currentlyViewing'], -1),
});
return mapStateToProps;
onLoadPending: () => dispatch(loadPending(timelineId)),
- updateCurrentlyViewing: id => dispatch(updateCurrentlyViewing(timelineId, id)),
});
export default connect(makeMapStateToProps, mapDispatchToProps)(StatusList);
TIMELINE_CONNECT,
TIMELINE_DISCONNECT,
TIMELINE_LOAD_PENDING,
- CURRENTLY_VIEWING,
} from '../actions/timelines';
import {
ACCOUNT_BLOCK_SUCCESS,
hasMore: true,
pendingItems: ImmutableList(),
items: ImmutableList(),
- currentlyViewing: -1,
});
const expandNormalizedTimeline = (state, timeline, statuses, next, isPartial, isLoadingRecent, usePendingItems) => {
initialTimeline,
map => map.set('online', false).update(action.usePendingItems ? 'pendingItems' : 'items', items => items.first() ? items.unshift(null) : items)
);
- case CURRENTLY_VIEWING:
- return state.update(action.timeline, initialTimeline, map => map.set('currentlyViewing', action.id));
default:
return state;
}