Buffer.tsx (983B)
1 import * as React from 'react'; 2 import { FlatList, ListRenderItem } from 'react-native'; 3 4 import BufferLine from './BufferLine'; 5 import { ParseShape } from 'react-native-parsed-text'; 6 7 interface Props { 8 lines: WeechatLine[]; 9 onLongPress: () => void; 10 parseArgs: ParseShape[]; 11 bufferId: string; 12 } 13 14 const keyExtractor = (line: WeechatLine) => 15 line.pointers[line.pointers.length - 1]; 16 17 export default class Buffer extends React.PureComponent<Props> { 18 renderBuffer: ListRenderItem<WeechatLine> = ({ item }) => { 19 const { onLongPress, parseArgs } = this.props; 20 21 return ( 22 <BufferLine line={item} onLongPress={onLongPress} parseArgs={parseArgs} /> 23 ); 24 }; 25 26 render(): JSX.Element { 27 const { lines } = this.props; 28 return ( 29 <FlatList 30 data={lines.filter((line) => line.displayed !== 0)} 31 inverted 32 keyboardDismissMode="interactive" 33 keyExtractor={keyExtractor} 34 renderItem={this.renderBuffer} 35 /> 36 ); 37 } 38 }