@@ -3,16 +3,19 @@ import React from 'react'
3
3
import TimeAgo from 'timeago-react'
4
4
5
5
import { ICON_CMD } from '../../config'
6
+ /* import { fakeUsers, getRandomInt, Global, prettyNum } from '../../utils' */
7
+ import { Global , prettyNum , uid } from '../../utils'
6
8
7
9
import {
8
10
AvatarsRow ,
9
11
Button ,
10
12
SpaceGrow ,
11
13
Pagi ,
12
14
CommentLoading ,
13
- MarkDownPreviewer ,
15
+ MarkDownRender ,
14
16
} from '../../components'
15
17
18
+ import * as logic from './logic'
16
19
import CommentsFilter from './CommentsFilter'
17
20
18
21
import {
@@ -49,17 +52,10 @@ import {
49
52
ReplyToFloor ,
50
53
} from './styles/comments_list'
51
54
52
- import * as logic from './logic'
53
- import { uid , Global , prettyNum , makeDebugger } from '../../utils'
54
-
55
- /* eslint-disable no-unused-vars */
56
- const debug = makeDebugger ( 'C:CommentsList' )
57
- /* eslint-enable no-unused-vars */
58
-
59
55
const getSelection = ( ) => {
60
56
const selectText = Global . getSelection ( ) . toString ( )
61
57
if ( ! R . isEmpty ( selectText ) ) {
62
- debug ( 'getSelection' , selectText )
58
+ /* console.log ('getSelection', selectText) */
63
59
// TODO: then use window.getSelection().getRangeAt(0).getBoundingClientRect() to draw a button
64
60
}
65
61
}
@@ -107,9 +103,11 @@ const ActionBottom = ({ data, accountInfo }) => {
107
103
}
108
104
109
105
const getAuthors = comment => {
106
+ /* eslint-disable no-return-assign */
110
107
const replies = R . forEach ( reply => {
111
108
return ( reply . author . extra_id = reply . id )
112
109
} , R . clone ( comment . replies ) )
110
+ /* eslint-enable */
113
111
114
112
return R . pluck ( 'author' , replies )
115
113
}
@@ -138,9 +136,7 @@ const Comment = ({ data, tobeDeleteId, accountInfo }) => (
138
136
total = { data . repliesCount }
139
137
/>
140
138
</ ReplyUsers >
141
- ) :(
142
- < div />
143
- ) }
139
+ ) :null }
144
140
</ CommentHeaderFirst >
145
141
< TimeStamps >
146
142
< TimeAgo datetime = { data . insertedAt } locale = "zh_CN" />
@@ -154,10 +150,8 @@ const Comment = ({ data, tobeDeleteId, accountInfo }) => (
154
150
< ReplyToBody > { data . replyTo . body } </ ReplyToBody >
155
151
< ReplyToFloor > #{ data . replyTo . floor } </ ReplyToFloor >
156
152
</ ReplyBar >
157
- ) :(
158
- < div />
159
- ) }
160
- < MarkDownPreviewer body = { data . body } />
153
+ ) :null }
154
+ < MarkDownRender body = { data . body } />
161
155
</ CommentContent >
162
156
< CommentFooter >
163
157
< Actions >
@@ -190,7 +184,7 @@ const Comment = ({ data, tobeDeleteId, accountInfo }) => (
190
184
)
191
185
192
186
const Lists = ( { entries, tobeDeleteId, accountInfo} ) => (
193
- < div >
187
+ < React . Fragment >
194
188
{ entries . map ( c => (
195
189
< div key = { uid . gen ( ) } >
196
190
< Comment
@@ -200,48 +194,33 @@ const Lists = ({ entries, tobeDeleteId, accountInfo }) => (
200
194
/>
201
195
</ div >
202
196
) ) }
203
- </ div >
197
+ </ React . Fragment >
204
198
)
205
199
206
- const TotalCountText = ( { count} ) => {
207
- return (
208
- < TotalCountWrapper >
209
- { count > 0 ?(
210
- < ListTitle id = "lists-info" >
211
- 收到< TotalNum > { count } </ TotalNum > 条评论:
212
- </ ListTitle >
213
- ) :(
214
- < div />
215
- ) }
216
- </ TotalCountWrapper >
217
- )
218
- }
200
+ const TotalCountText = ( { count} ) => (
201
+ < TotalCountWrapper >
202
+ { count > 0 ?(
203
+ < ListTitle id = "lists-info" >
204
+ 共收到< TotalNum > { count } </ TotalNum > 条评论:
205
+ </ ListTitle >
206
+ ) :null }
207
+ </ TotalCountWrapper >
208
+ )
219
209
220
210
const CommentsList = ( {
221
- entries,
222
211
accountInfo,
223
- restProps :{
224
- totalCount,
225
- pageSize,
226
- pageNumber,
227
- loading,
228
- loadingFresh,
229
- tobeDeleteId,
230
- filterType,
231
- } ,
212
+ pagedComments :{ entries, totalCount, pageSize, pageNumber} ,
213
+ restProps :{ loading, loadingFresh, tobeDeleteId, filterType} ,
232
214
} ) => (
233
- < div >
215
+ < React . Fragment >
234
216
< TotalHeader >
235
217
< TotalCountText count = { totalCount } />
236
- < CommentsFilter filterType = { filterType } />
218
+ < CommentsFilter filterType = { filterType } show = { totalCount >= 2 } />
237
219
</ TotalHeader >
238
-
239
- { loadingFresh ?(
220
+ { ! loadingFresh ?null :(
240
221
< CommentBlock >
241
222
< CommentLoading />
242
223
</ CommentBlock >
243
- ) :(
244
- < div />
245
224
) }
246
225
< ListsContainer >
247
226
{ loading ?(
@@ -258,15 +237,17 @@ const CommentsList = ({
258
237
/>
259
238
) }
260
239
</ ListsContainer >
261
-
262
240
< Pagi
263
241
left = "-10px"
264
242
pageNumber = { pageNumber }
265
243
pageSize = { pageSize }
266
244
totalCount = { totalCount }
267
245
onChange = { logic . pageChange }
246
+ showBottomMsg
247
+ noMoreMsg = "没有更多的评论了"
248
+ emptyMsg = "目前还没有评论"
268
249
/>
269
- </ div >
250
+ </ React . Fragment >
270
251
)
271
252
272
253
export default CommentsList