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 Forum Loading Screen Text (#4102) #4324

Merged
merged 9 commits into from
Apr 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion packages/ui/src/app/pages/Forum/ForumCategory.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export const ForumCategory = () => {
const { id, type } = useParams<{ id: string; type?: 'archive' }>()
const isArchive = type === 'archive'

const { category } = useForumCategory(id)
const { category, isLoading: isLoadingCategory, hasError } = useForumCategory(id)
const { order, getSortProps } = useSort<ForumThreadOrderByInput>('updatedAt')
const {
isLoading: isLoadingThreads,
Expand All @@ -59,6 +59,14 @@ export const ForumCategory = () => {
return <Loading />
}

if (isLoadingCategory) {
return <Loading />
}

if (hasError) {
return <EmptyPagePlaceholder title="Something went wrong fetching this category." copy="" button={null} />
}

if (!category) {
return <EmptyPagePlaceholder title="There is no data in the category" copy="" button={null} />
}
Expand Down
4 changes: 2 additions & 2 deletions packages/ui/src/forum/hooks/useForumCategory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import { useGetForumCategoryQuery } from '@/forum/queries'
import { asCategoryWithDetails } from '@/forum/types/ForumCategoryWithDetails'

export const useForumCategory = (id: string) => {
const { loading, data } = useGetForumCategoryQuery({ variables: { where: { id } } })

const { loading, data, error } = useGetForumCategoryQuery({ variables: { where: { id } } })
return {
isLoading: loading,
category: data?.forumCategoryByUniqueInput && asCategoryWithDetails(data.forumCategoryByUniqueInput),
hasError: !!error,
}
}