mirror of
https://github.com/wassname/talk.git
synced 2026-08-11 11:27:10 +08:00
Live update replies on all sort and always refetch
This commit is contained in:
@@ -84,6 +84,10 @@ class StreamContainer extends React.Component {
|
||||
return prev;
|
||||
}
|
||||
|
||||
// Newest top-level comments are only added when sorting by 'newest first'.
|
||||
if (!commentAdded.parent && !this.isSortedByNewestFirst()) {
|
||||
return prev;
|
||||
}
|
||||
return insertCommentIntoEmbedQuery(prev, commentAdded);
|
||||
},
|
||||
});
|
||||
@@ -163,32 +167,9 @@ class StreamContainer extends React.Component {
|
||||
}
|
||||
|
||||
componentWillReceiveProps(nextProps) {
|
||||
const prevSortedNewest = this.isSortedByNewestFirst(this.props);
|
||||
const nextSortedNewest = this.isSortedByNewestFirst(nextProps);
|
||||
|
||||
// When switching to 'Newest first' we refetch and subscribe so that
|
||||
// we always have the newest comments.
|
||||
if (!prevSortedNewest && nextSortedNewest) {
|
||||
if (this.props.sortOrder !== nextProps.sortOrder || this.props.sortBy !== nextProps.sortBy) {
|
||||
nextProps.data.refetch();
|
||||
this.subscribeToCommentsAdded();
|
||||
}
|
||||
|
||||
// When switching away from 'Newest first' unsubscribe from newest comments.
|
||||
if (prevSortedNewest && !nextSortedNewest) {
|
||||
this.unsubscribeCommentsAdded();
|
||||
}
|
||||
}
|
||||
|
||||
shouldComponentUpdate(nextProps) {
|
||||
const prevSortedNewest = this.isSortedByNewestFirst(this.props);
|
||||
const nextSortedNewest = this.isSortedByNewestFirst(nextProps);
|
||||
if (!prevSortedNewest && nextSortedNewest) {
|
||||
|
||||
// When switching to 'Newest first' we refetch => skip
|
||||
// rendering this frame and wait for refetch to kick in.
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
userIsDegraged({auth: {user}} = this.props) {
|
||||
|
||||
Reference in New Issue
Block a user