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 cachedComments = useAppSelector((state) => state.cache.comments);
|
||||||
|
|
||||||
const [lcomments, setLComments] = useState([]);
|
const [lcomments, setLComments] = useState([]);
|
||||||
const [replies, setReplies] = useState(comments);
|
const [propComments, setPropComments] = useState(comments);
|
||||||
const [selectedPermlink, setSelectedPermlink] = useState('');
|
const [selectedPermlink, setSelectedPermlink] = useState('');
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@ -65,6 +65,12 @@ const CommentsContainer = ({
|
|||||||
setLComments(shortedComments);
|
setLComments(shortedComments);
|
||||||
}, [commentCount, selectedFilter]);
|
}, [commentCount, selectedFilter]);
|
||||||
|
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
setPropComments(comments);
|
||||||
|
}, [comments]);
|
||||||
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const postPath = `${author || ''}/${permlink || ''}`;
|
const postPath = `${author || ''}/${permlink || ''}`;
|
||||||
//this conditional makes sure on targetted already fetched post is updated
|
//this conditional makes sure on targetted already fetched post is updated
|
||||||
@ -162,7 +168,7 @@ const CommentsContainer = ({
|
|||||||
const _getComments = async () => {
|
const _getComments = async () => {
|
||||||
if (isOwnProfile) {
|
if (isOwnProfile) {
|
||||||
fetchPost();
|
fetchPost();
|
||||||
} else if (author && permlink && !replies) {
|
} else if (author && permlink && !propComments) {
|
||||||
await getComments(author, permlink, name)
|
await getComments(author, permlink, name)
|
||||||
.then((__comments) => {
|
.then((__comments) => {
|
||||||
//TODO: favourable place for merging comment cache
|
//TODO: favourable place for merging comment cache
|
||||||
@ -181,7 +187,7 @@ const CommentsContainer = ({
|
|||||||
};
|
};
|
||||||
|
|
||||||
const _handleCachedComment = (passedComments = null) => {
|
const _handleCachedComment = (passedComments = null) => {
|
||||||
const _comments = passedComments || replies || lcomments;
|
const _comments = passedComments || propComments || lcomments;
|
||||||
const postPath = `${author || ''}/${permlink || ''}`;
|
const postPath = `${author || ''}/${permlink || ''}`;
|
||||||
|
|
||||||
if (cachedComments.has(postPath)) {
|
if (cachedComments.has(postPath)) {
|
||||||
@ -215,8 +221,8 @@ const CommentsContainer = ({
|
|||||||
console.log('updated comments with cached comment');
|
console.log('updated comments with cached comment');
|
||||||
if (passedComments) {
|
if (passedComments) {
|
||||||
return newComments;
|
return newComments;
|
||||||
} else if (replies) {
|
} else if (propComments) {
|
||||||
setReplies(newComments);
|
setPropComments(newComments);
|
||||||
} else {
|
} else {
|
||||||
setLComments(newComments);
|
setLComments(newComments);
|
||||||
}
|
}
|
||||||
@ -278,8 +284,8 @@ const CommentsContainer = ({
|
|||||||
filteredComments = lcomments.filter(_applyFilter);
|
filteredComments = lcomments.filter(_applyFilter);
|
||||||
setLComments(filteredComments);
|
setLComments(filteredComments);
|
||||||
} else {
|
} else {
|
||||||
filteredComments = replies.filter(_applyFilter);
|
filteredComments = propComments.filter(_applyFilter);
|
||||||
setReplies(filteredComments);
|
setPropComments(filteredComments);
|
||||||
}
|
}
|
||||||
|
|
||||||
// remove cached entry based on parent
|
// remove cached entry based on parent
|
||||||
@ -331,7 +337,7 @@ const CommentsContainer = ({
|
|||||||
mainAuthor={mainAuthor}
|
mainAuthor={mainAuthor}
|
||||||
commentNumber={commentNumber || 1}
|
commentNumber={commentNumber || 1}
|
||||||
commentCount={commentCount}
|
commentCount={commentCount}
|
||||||
comments={lcomments.length > 0 ? lcomments : replies}
|
comments={lcomments.length > 0 ? lcomments : propComments}
|
||||||
currentAccountUsername={currentAccount.name}
|
currentAccountUsername={currentAccount.name}
|
||||||
handleOnEditPress={_handleOnEditPress}
|
handleOnEditPress={_handleOnEditPress}
|
||||||
handleOnReplyPress={_handleOnReplyPress}
|
handleOnReplyPress={_handleOnReplyPress}
|
||||||
|
Loading…
Reference in New Issue
Block a user