Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: issue 4485, check 4484 #4508

Merged
merged 2 commits into from
Aug 31, 2023
Merged

Fix: issue 4485, check 4484 #4508

merged 2 commits into from
Aug 31, 2023

Conversation

mkbeefcake
Copy link
Contributor

Fixed #4485 and checked #4484

@vercel
Copy link

vercel bot commented Aug 30, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
dao ✅ Ready (Inspect) Visit Preview Aug 31, 2023 1:41pm
pioneer-2 ✅ Ready (Inspect) Visit Preview Aug 31, 2023 1:41pm
pioneer-2-storybook ✅ Ready (Inspect) Visit Preview Aug 31, 2023 1:41pm

Comment on lines -58 to -61
if (isLoadingThreads && !isRefetched) {
return <Loading />
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work on catching this ! It wasn't an easy one to debug 🤯

But I think the fix could be improved because first it now makes empty categories show a loader every 6 seconds e.g: https://dao-git-fork-mkbeefcake-fix-4485-4484-joystream.vercel.app/#/forum/category/17?network-config=https://34.230.5.182.nip.io/network/config.json. But more importantly it still refetch way to much data (as you pointed out on #4484). Also I realized we've struggled with this particular useRefetch for a long time (see #4318) so I really think the best is to remove this one.

Instead we could replace this logic by a pollInterval of 6 second in packages/ui/src/forum/hooks/useForumCategoryThreads.ts but only when isArchive is false. Also isLoading should become !threadsData || !countData this way isLoading is only true on the initial load.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image
Thanks for your guide. also I figured out "posts" field in forumThreads query, If i choose this mechanism, i can reduce the query count to 1, but it could take all posts info per each thread, so could take much data and a bit more loading time.
I hope to get your opinion about this.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes forumThreads { posts { ... } } will return all the posts for all the threads shown one the category page so I think 1 request per thread is a better trade off.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@thesan I have added posts field for ForumThread interface and fetched it in GetForumThreads Query, so reduce the queries in Forum Category page, please check the updated code.

@@ -42,7 +42,7 @@ export const ThreadList = ({
return <NotFoundText>No threads found</NotFoundText>
}

if (isLoading) {
if (isLoading && threads.length <= 0) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey, please reverse the changes to this file it's not needed anymore

Comment on lines 125 to 144
posts {
id
createdAt
isVisible
text
authorId
edits {
createdAt
}
status {
__typename
}
threadId
thread {
categoryId
}
author {
...MemberFields
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we should go with this solution:
ATM on the Joystream General category it ~6x the size of the thread requests from 137kb to 851kb but the 30 posts request saved by this solution were between 4kb to 10kb so already the page queries a lot more data to start with. And then it repeats the thread request every 6 seconds. On top of that the thread request go all the way to several megabytes on some pages.

A bigger request can often be better than a lot of smaller one but here I really don't think this is worth it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have removed "posts" from thread and updated the code. please review and give me feedback

@thesan thesan merged commit 5914307 into Joystream:dev Aug 31, 2023
3 checks passed
@thesan thesan added the community-dev issue suitable for community-dev pipeline label Oct 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
community-dev issue suitable for community-dev pipeline
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Forum: Category pages refreshing multiple times before loading
2 participants