mirror of
https://github.com/gurnec/removeddit.git
synced 2026-03-11 08:54:27 +00:00
Add feedback after 'load more comments' completes
This commit is contained in:
parent
fb327e7b94
commit
94d4514922
5 changed files with 42 additions and 25 deletions
2
dist/main.css
vendored
2
dist/main.css
vendored
File diff suppressed because one or more lines are too long
|
|
@ -1,25 +1,37 @@
|
|||
import React from 'react'
|
||||
import {connect, getMaxComments, maxCommentsDefault} from '../../state'
|
||||
|
||||
let lastTotal
|
||||
const loadMoreComments = (props, maxComments) => {
|
||||
lastTotal = props.total
|
||||
props.global.loadMoreComments(maxComments)
|
||||
}
|
||||
|
||||
const loadMore = (props) => {
|
||||
const maxCommentsPreferred = getMaxComments()
|
||||
let loadElements
|
||||
|
||||
if (props.reloadingComments)
|
||||
return <p className='loading-more'><span>loading...</span></p>
|
||||
else if (props.loadedAllComments)
|
||||
return <p className='load-more'>
|
||||
<a onClick={() => props.global.loadMoreComments(maxCommentsDefault)}>load new comments</a>
|
||||
</p>
|
||||
else
|
||||
return <p className='load-more'>
|
||||
{maxCommentsPreferred <= maxCommentsDefault / 2 &&
|
||||
<a onClick={() => props.global.loadMoreComments(maxCommentsPreferred)}>load {maxCommentsPreferred} more comments</a>
|
||||
}
|
||||
<a onClick={() => props.global.loadMoreComments(maxCommentsDefault)}>load {maxCommentsDefault} more comments</a>
|
||||
{maxCommentsPreferred >= maxCommentsDefault * 2 &&
|
||||
<a onClick={() => props.global.loadMoreComments(maxCommentsPreferred)}>load {maxCommentsPreferred} more comments</a>
|
||||
}
|
||||
</p>
|
||||
loadElements = [<span key='loading'>loading...</span>]
|
||||
else {
|
||||
if (props.loadedAllComments)
|
||||
loadElements = [<a key='default' onClick={() => loadMoreComments(props, maxCommentsDefault)}>load new comments</a>]
|
||||
else {
|
||||
loadElements = []
|
||||
if (maxCommentsPreferred <= maxCommentsDefault / 2)
|
||||
loadElements.push(<a key='pref' onClick={() => loadMoreComments(props, maxCommentsPreferred)}>load {maxCommentsPreferred} more comments</a>)
|
||||
loadElements.push(<a key='default' onClick={() => loadMoreComments(props, maxCommentsDefault)}>load {maxCommentsDefault} more comments</a>)
|
||||
if (maxCommentsPreferred >= maxCommentsDefault * 2)
|
||||
loadElements.push(<a key='pref' onClick={() => loadMoreComments(props, maxCommentsPreferred)}>load {maxCommentsPreferred} more comments</a>)
|
||||
}
|
||||
if (lastTotal !== undefined) {
|
||||
const newComments = props.total - lastTotal
|
||||
loadElements.push(<span key='loaded' className='fade'>
|
||||
{newComments > 0 ? `loaded ${newComments} more comments` : 'no new comments found'}
|
||||
</span>)
|
||||
}
|
||||
}
|
||||
return <p className='load-more'>{loadElements}</p>
|
||||
}
|
||||
|
||||
export default connect(loadMore)
|
||||
|
|
|
|||
|
|
@ -227,6 +227,7 @@ class Thread extends React.Component {
|
|||
<LoadMore
|
||||
loadedAllComments={this.state.loadedAllComments}
|
||||
reloadingComments={this.state.reloadingComments}
|
||||
total={this.state.pushshiftCommentLookup.size}
|
||||
/>
|
||||
</>
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,8 +24,6 @@
|
|||
@keyframes highlighted-anim
|
||||
0%
|
||||
background-color: lightblue
|
||||
100%
|
||||
background-color: #161616
|
||||
|
||||
.question
|
||||
font-size: 18px
|
||||
|
|
|
|||
|
|
@ -142,14 +142,20 @@
|
|||
margin-bottom: 10px
|
||||
|
||||
|
||||
.load-more a
|
||||
font-weight: bold
|
||||
font-size: 10px
|
||||
.load-more
|
||||
font-weight: bold
|
||||
font-size: 10px
|
||||
|
||||
a
|
||||
margin-left: 16px
|
||||
cursor: pointer
|
||||
|
||||
.loading-more span
|
||||
color: $link
|
||||
font-weight: bold
|
||||
font-size: 10px
|
||||
span
|
||||
margin-left: 16px
|
||||
|
||||
.fade
|
||||
animation: fade-anim 3s 2s ease-in-out forwards
|
||||
|
||||
@keyframes fade-anim
|
||||
100%
|
||||
color: $background
|
||||
|
|
|
|||
Loading…
Reference in a new issue