mirror of
https://github.com/ecency/ecency-mobile.git
synced 2024-12-21 12:21:31 +03:00
Merge branch 'development' of https://github.com/ecency/ecency-mobile into sa/notifications-scroll-bug
This commit is contained in:
commit
09c2945666
@ -52,7 +52,7 @@ const CommentsContainer = ({
|
||||
const cachedComments = useAppSelector((state) => state.cache.comments);
|
||||
|
||||
const [lcomments, setLComments] = useState([]);
|
||||
const [replies, setReplies] = useState(comments);
|
||||
const [propComments, setPropComments] = useState(comments);
|
||||
const [selectedPermlink, setSelectedPermlink] = useState('');
|
||||
|
||||
useEffect(() => {
|
||||
@ -65,6 +65,12 @@ const CommentsContainer = ({
|
||||
setLComments(shortedComments);
|
||||
}, [commentCount, selectedFilter]);
|
||||
|
||||
|
||||
useEffect(() => {
|
||||
setPropComments(comments);
|
||||
}, [comments]);
|
||||
|
||||
|
||||
useEffect(() => {
|
||||
const postPath = `${author || ''}/${permlink || ''}`;
|
||||
//this conditional makes sure on targetted already fetched post is updated
|
||||
@ -162,7 +168,7 @@ const CommentsContainer = ({
|
||||
const _getComments = async () => {
|
||||
if (isOwnProfile) {
|
||||
fetchPost();
|
||||
} else if (author && permlink && !replies) {
|
||||
} else if (author && permlink && !propComments) {
|
||||
await getComments(author, permlink, name)
|
||||
.then((__comments) => {
|
||||
//TODO: favourable place for merging comment cache
|
||||
@ -181,7 +187,7 @@ const CommentsContainer = ({
|
||||
};
|
||||
|
||||
const _handleCachedComment = (passedComments = null) => {
|
||||
const _comments = passedComments || replies || lcomments;
|
||||
const _comments = passedComments || propComments || lcomments;
|
||||
const postPath = `${author || ''}/${permlink || ''}`;
|
||||
|
||||
if (cachedComments.has(postPath)) {
|
||||
@ -215,8 +221,8 @@ const CommentsContainer = ({
|
||||
console.log('updated comments with cached comment');
|
||||
if (passedComments) {
|
||||
return newComments;
|
||||
} else if (replies) {
|
||||
setReplies(newComments);
|
||||
} else if (propComments) {
|
||||
setPropComments(newComments);
|
||||
} else {
|
||||
setLComments(newComments);
|
||||
}
|
||||
@ -278,8 +284,8 @@ const CommentsContainer = ({
|
||||
filteredComments = lcomments.filter(_applyFilter);
|
||||
setLComments(filteredComments);
|
||||
} else {
|
||||
filteredComments = replies.filter(_applyFilter);
|
||||
setReplies(filteredComments);
|
||||
filteredComments = propComments.filter(_applyFilter);
|
||||
setPropComments(filteredComments);
|
||||
}
|
||||
|
||||
// remove cached entry based on parent
|
||||
@ -331,7 +337,7 @@ const CommentsContainer = ({
|
||||
mainAuthor={mainAuthor}
|
||||
commentNumber={commentNumber || 1}
|
||||
commentCount={commentCount}
|
||||
comments={lcomments.length > 0 ? lcomments : replies}
|
||||
comments={lcomments.length > 0 ? lcomments : propComments}
|
||||
currentAccountUsername={currentAccount.name}
|
||||
handleOnEditPress={_handleOnEditPress}
|
||||
handleOnReplyPress={_handleOnReplyPress}
|
||||
|
Loading…
Reference in New Issue
Block a user