@@ -3,16 +3,19 @@ import React from 'react'
33import TimeAgo from 'timeago-react'
44
55import { ICON_CMD } from '../../config'
6+ /* import { fakeUsers, getRandomInt, Global, prettyNum } from '../../utils' */
7+ import { Global , prettyNum , uid } from '../../utils'
68
79import {
810 AvatarsRow ,
911 Button ,
1012 SpaceGrow ,
1113 Pagi ,
1214 CommentLoading ,
13- MarkDownPreviewer ,
15+ MarkDownRender ,
1416} from '../../components'
1517
18+ import * as logic from './logic'
1619import CommentsFilter from './CommentsFilter'
1720
1821import {
@@ -49,17 +52,10 @@ import {
4952 ReplyToFloor ,
5053} from './styles/comments_list'
5154
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-
5955const getSelection = ( ) => {
6056 const selectText = Global . getSelection ( ) . toString ( )
6157 if ( ! R . isEmpty ( selectText ) ) {
62- debug ( 'getSelection' , selectText )
58+ /* console.log ('getSelection', selectText) */
6359 // TODO: then use window.getSelection().getRangeAt(0).getBoundingClientRect() to draw a button
6460 }
6561}
@@ -107,9 +103,11 @@ const ActionBottom = ({ data, accountInfo }) => {
107103}
108104
109105const getAuthors = comment => {
106+ /* eslint-disable no-return-assign */
110107 const replies = R . forEach ( reply => {
111108 return ( reply . author . extra_id = reply . id )
112109 } , R . clone ( comment . replies ) )
110+ /* eslint-enable */
113111
114112 return R . pluck ( 'author' , replies )
115113}
@@ -138,9 +136,7 @@ const Comment = ({ data, tobeDeleteId, accountInfo }) => (
138136 total = { data . repliesCount }
139137 />
140138 </ ReplyUsers >
141- ) : (
142- < div />
143- ) }
139+ ) : null }
144140 </ CommentHeaderFirst >
145141 < TimeStamps >
146142 < TimeAgo datetime = { data . insertedAt } locale = "zh_CN" />
@@ -154,10 +150,8 @@ const Comment = ({ data, tobeDeleteId, accountInfo }) => (
154150 < ReplyToBody > { data . replyTo . body } </ ReplyToBody >
155151 < ReplyToFloor > #{ data . replyTo . floor } </ ReplyToFloor >
156152 </ ReplyBar >
157- ) : (
158- < div />
159- ) }
160- < MarkDownPreviewer body = { data . body } />
153+ ) : null }
154+ < MarkDownRender body = { data . body } />
161155 </ CommentContent >
162156 < CommentFooter >
163157 < Actions >
@@ -190,7 +184,7 @@ const Comment = ({ data, tobeDeleteId, accountInfo }) => (
190184)
191185
192186const Lists = ( { entries, tobeDeleteId, accountInfo } ) => (
193- < div >
187+ < React . Fragment >
194188 { entries . map ( c => (
195189 < div key = { uid . gen ( ) } >
196190 < Comment
@@ -200,48 +194,33 @@ const Lists = ({ entries, tobeDeleteId, accountInfo }) => (
200194 />
201195 </ div >
202196 ) ) }
203- </ div >
197+ </ React . Fragment >
204198)
205199
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+ )
219209
220210const CommentsList = ( {
221- entries,
222211 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 } ,
232214} ) => (
233- < div >
215+ < React . Fragment >
234216 < TotalHeader >
235217 < TotalCountText count = { totalCount } />
236- < CommentsFilter filterType = { filterType } />
218+ < CommentsFilter filterType = { filterType } show = { totalCount >= 2 } />
237219 </ TotalHeader >
238-
239- { loadingFresh ? (
220+ { ! loadingFresh ? null : (
240221 < CommentBlock >
241222 < CommentLoading />
242223 </ CommentBlock >
243- ) : (
244- < div />
245224 ) }
246225 < ListsContainer >
247226 { loading ? (
@@ -258,15 +237,17 @@ const CommentsList = ({
258237 />
259238 ) }
260239 </ ListsContainer >
261-
262240 < Pagi
263241 left = "-10px"
264242 pageNumber = { pageNumber }
265243 pageSize = { pageSize }
266244 totalCount = { totalCount }
267245 onChange = { logic . pageChange }
246+ showBottomMsg
247+ noMoreMsg = "没有更多的评论了"
248+ emptyMsg = "目前还没有评论"
268249 />
269- </ div >
250+ </ React . Fragment >
270251)
271252
272253export default CommentsList
0 commit comments