Skip to content

Commit

Permalink
Fix/library title size info initial render flickering (#350)
Browse files Browse the repository at this point in the history
* Rename variable

* Hide size tag until tabs data was loaded

The wrong loading state (mangas) was being used to check if the size tag can be shown.
  • Loading branch information
schroda authored Jun 4, 2023
1 parent 00e403c commit 1ec6d77
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/screens/Library.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export default function Library() {

const { options } = useLibraryOptionsContext();
const [lastLibraryUpdate, setLastLibraryUpdate] = useState(Date.now());
const { data: tabsData, error: tabsError, isLoading } = requestManager.useGetCategories();
const { data: tabsData, error: tabsError, isLoading: areCategoriesLoading } = requestManager.useGetCategories();
const tabs = tabsData ?? [];
const librarySize = useMemo(() => tabs.map((tab) => tab.size).reduce((prev, curr) => prev + curr, 0), [tabs]);

Expand All @@ -55,7 +55,7 @@ export default function Library() {
const navBarTitle = (
<TitleWithSizeTag>
{title}
{mangaLoading || !options.showTabSize ? null : <TitleSizeTag label={librarySize} />}
{areCategoriesLoading || !options.showTabSize ? null : <TitleSizeTag label={librarySize} />}
</TitleWithSizeTag>
);
setTitle(navBarTitle, title);
Expand All @@ -70,7 +70,7 @@ export default function Library() {
setTitle('');
setAction(null);
};
}, [t, librarySize, mangaLoading, options]);
}, [t, librarySize, areCategoriesLoading, options]);

const handleTabChange = (newTab: number) => {
setTabSearchParam(newTab === 0 ? undefined : newTab);
Expand All @@ -85,7 +85,7 @@ export default function Library() {
);
}

if (isLoading) {
if (areCategoriesLoading) {
return <LoadingPlaceholder />;
}

Expand Down

0 comments on commit 1ec6d77

Please sign in to comment.