@ -15,6 +15,7 @@ class List extends Component {
constructor ( props ) {
constructor ( props ) {
super ( props ) ;
super ( props ) ;
this . state = {
this . state = {
messageList : props . messageList . slice ( 0 , 1 ) ,
counter : 1 ,
counter : 1 ,
id : window . location . href . split ( '/' ) . pop ( ) * 1 ,
id : window . location . href . split ( '/' ) . pop ( ) * 1 ,
data : { } ,
data : { } ,
@ -27,8 +28,17 @@ class List extends Component {
document : null ,
document : null ,
} ;
} ;
}
}
addcounter ( ) {
addcounter ( item ) {
this . setState ( { counter : this . state . counter + 1 } ) ;
let { messageList } = this . state ;
const last = messageList . slice ( - 1 ) [ 0 ] || { } ;
console . log ( item ) ;
if ( ! item ) {
messageList . push ( this . props . messageList . find ( ( e ) => e . pid == last . id ) ) ;
} else {
messageList . push ( this . props . messageList . find ( ( e ) => e . id == item . id ) ) ;
}
this . setState ( { messageList } ) ;
}
}
start = ( ) => {
start = ( ) => {
this . setState ( {
this . setState ( {
@ -344,7 +354,8 @@ class List extends Component {
}
}
render ( ) {
render ( ) {
const { setPage , chatInfo , messageList : msaster , userId } = this . props ; //last
const { setPage , chatInfo , messageList : msaster , userId } = this . props ; //last
const messageList = msaster . slice ( 0 , this . state . counter ) ;
const { messageList } = this . state ;
// const messageList = msaster.slice(0, this.state.counter);
const last = messageList . slice ( - 1 ) [ 0 ] || { } ;
const last = messageList . slice ( - 1 ) [ 0 ] || { } ;
const userIdx = this . userIdx || { } ;
const userIdx = this . userIdx || { } ;
if ( Object . keys ( userIdx ) . length == 0 ) {
if ( Object . keys ( userIdx ) . length == 0 ) {
@ -367,6 +378,9 @@ class List extends Component {
overflowY : this . state . file !== null ? 'hidden' : 'scroll' ,
overflowY : this . state . file !== null ? 'hidden' : 'scroll' ,
paddingBottom : last . action === 'keyboard' ? 150 : 75 ,
paddingBottom : last . action === 'keyboard' ? 150 : 75 ,
} }
} }
onClick = { ( ) => {
if ( last . action === 'tap' ) this . addcounter ( ) ;
} }
>
>
{ chatInfo . users &&
{ chatInfo . users &&
messageList . map ( ( message , i ) =>
messageList . map ( ( message , i ) =>
@ -434,7 +448,12 @@ class List extends Component {
/ >
/ >
) : null }
) : null }
{ last . action === 'keyboard' ? (
{ last . action === 'keyboard' ? (
< Keyboard options = { last . options } addcounter = { ( ) => this . addcounter ( ) } / >
< Keyboard
options = { last . options }
action = { ( item ) => {
this . addcounter ( item ) ;
} }
/ >
) : null }
) : null }
< / d i v >
< / d i v >
< ToastContainer
< ToastContainer