This repository was archived by the owner on Feb 23, 2021. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +21
-6
lines changed
Expand file tree Collapse file tree 3 files changed +21
-6
lines changed Original file line number Diff line number Diff line change @@ -15,6 +15,9 @@ class LogAction {
1515 _ipcRenderer = ipcRenderer ;
1616 _ipcRenderer . on ( 'logs' , ( event , arg ) => {
1717 store . logs . push ( arg ) ;
18+ if ( store . logs . length > 100 ) {
19+ store . logs . splice ( 0 , store . logs . length - 100 ) ;
20+ }
1821 } ) ;
1922 _ipcRenderer . send ( 'logs-ready' , true ) ;
2023 }
Original file line number Diff line number Diff line change @@ -53,9 +53,15 @@ export class List extends Component {
5353 render ( ) {
5454 return (
5555 < ListView
56+ ref = { component => ( this . list = component ) }
5657 dataSource = { this . dataSource }
5758 renderHeader = { this . props . renderHeader }
58- renderRow = { this . props . renderItem }
59+ renderRow = { data => {
60+ this . props . scrollToEnd
61+ ? setTimeout ( ( ) => this . list . _scrollViewRef . scrollToEnd ( ) , 50 )
62+ : null ;
63+ return this . props . renderItem ( data ) ;
64+ } }
5965 enableEmptySections = { true }
6066 />
6167 ) ;
@@ -66,6 +72,7 @@ List.propTypes = {
6672 data : PropTypes . array . isRequired ,
6773 renderHeader : PropTypes . func ,
6874 renderItem : PropTypes . func . isRequired ,
75+ scrollToEnd : PropTypes . bool ,
6976} ;
7077
7178//
Original file line number Diff line number Diff line change 11import React from 'react' ;
22import { StyleSheet } from 'react-native' ;
3+ import { observer } from 'mobx-react' ;
34import PropTypes from 'prop-types' ;
45import Background from '../component/background' ;
5- import MainContent from '../component/main-content' ;
66import { Header , Title } from '../component/header' ;
77import Text from '../component/text' ;
8+ import { List , ListContent } from '../component/list' ;
89import { Button , BackButton } from '../component/button' ;
910import { color , font } from '../component/style' ;
1011
@@ -29,9 +30,13 @@ const CLIView = ({ store, nav }) => (
2930 < Button disabled onPress = { ( ) => { } } />
3031 </ Header >
3132 < Background color = { color . cliBackground } >
32- < MainContent style = { styles . content } >
33- { store . logs . map ( ( log , i ) => < LogItem text = { log } key = { i } /> ) }
34- </ MainContent >
33+ < ListContent >
34+ < List
35+ data = { store . logs . slice ( ) }
36+ renderItem = { text => < LogItem text = { text } /> }
37+ scrollToEnd = { true }
38+ />
39+ </ ListContent >
3540 </ Background >
3641 </ Background >
3742) ;
@@ -54,4 +59,4 @@ LogItem.propTypes = {
5459 text : PropTypes . string ,
5560} ;
5661
57- export default CLIView ;
62+ export default observer ( CLIView ) ;
You can’t perform that action at this time.
0 commit comments