diff options
author | Starfall <us@starfall.systems> | 2023-04-14 19:22:47 -0500 |
---|---|---|
committer | Starfall <us@starfall.systems> | 2023-04-14 19:22:47 -0500 |
commit | 4fe1689de43f4404eb9530fcfbcbfb26d6c1c13a (patch) | |
tree | 6811b845bb7f4966b10dcefa3dea404246f161c7 /app/javascript/flavours/glitch/features/direct_timeline/components/conversations_list.js | |
parent | 65c1e53a32cabcdbb7bca57002bb0f6acdebe07e (diff) | |
parent | bed63f6dae0879ac840066b031229e0d139089cd (diff) |
Diffstat (limited to 'app/javascript/flavours/glitch/features/direct_timeline/components/conversations_list.js')
-rw-r--r-- | app/javascript/flavours/glitch/features/direct_timeline/components/conversations_list.js | 75 |
1 files changed, 0 insertions, 75 deletions
diff --git a/app/javascript/flavours/glitch/features/direct_timeline/components/conversations_list.js b/app/javascript/flavours/glitch/features/direct_timeline/components/conversations_list.js deleted file mode 100644 index c2aff1b57..000000000 --- a/app/javascript/flavours/glitch/features/direct_timeline/components/conversations_list.js +++ /dev/null @@ -1,75 +0,0 @@ -import React from 'react'; -import PropTypes from 'prop-types'; -import ImmutablePropTypes from 'react-immutable-proptypes'; -import ImmutablePureComponent from 'react-immutable-pure-component'; -import ConversationContainer from '../containers/conversation_container'; -import ScrollableList from 'flavours/glitch/components/scrollable_list'; -import { debounce } from 'lodash'; - -export default class ConversationsList extends ImmutablePureComponent { - - static propTypes = { - conversations: ImmutablePropTypes.list.isRequired, - scrollKey: PropTypes.string.isRequired, - hasMore: PropTypes.bool, - isLoading: PropTypes.bool, - onLoadMore: PropTypes.func, - }; - - getCurrentIndex = id => this.props.conversations.findIndex(x => x.get('id') === id) - - handleMoveUp = id => { - const elementIndex = this.getCurrentIndex(id) - 1; - this._selectChild(elementIndex, true); - } - - handleMoveDown = id => { - const elementIndex = this.getCurrentIndex(id) + 1; - this._selectChild(elementIndex, false); - } - - _selectChild (index, align_top) { - const container = this.node.node; - const element = container.querySelector(`article:nth-of-type(${index + 1}) .focusable`); - - if (element) { - if (align_top && container.scrollTop > element.offsetTop) { - element.scrollIntoView(true); - } else if (!align_top && container.scrollTop + container.clientHeight < element.offsetTop + element.offsetHeight) { - element.scrollIntoView(false); - } - element.focus(); - } - } - - setRef = c => { - this.node = c; - } - - handleLoadOlder = debounce(() => { - const last = this.props.conversations.last(); - - if (last && last.get('last_status')) { - this.props.onLoadMore(last.get('last_status')); - } - }, 300, { leading: true }) - - render () { - const { conversations, onLoadMore, ...other } = this.props; - - return ( - <ScrollableList {...other} onLoadMore={onLoadMore && this.handleLoadOlder} ref={this.setRef}> - {conversations.map(item => ( - <ConversationContainer - key={item.get('id')} - conversationId={item.get('id')} - onMoveUp={this.handleMoveUp} - onMoveDown={this.handleMoveDown} - scrollKey={this.props.scrollKey} - /> - ))} - </ScrollableList> - ); - } - -} |