Skip to content

Commit

Permalink
fix: delay loading of percentageFromCfi until displayedCFI is ready.
Browse files Browse the repository at this point in the history
  • Loading branch information
Neulus committed Jul 5, 2024
1 parent c711611 commit 24a6b4d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
8 changes: 6 additions & 2 deletions src/routes/Reader/ProgressMenu/ProgressMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,11 @@ const ProgressInfoBar = ()=>{
}

}


// wait until displayedCFI is loaded
if (!displayedCFI) {
return <BottomMenuContainer active={menuActive}></BottomMenuContainer>;
}
const currentPercentage = renditionInstance?.book.locations.percentageFromCfi(displayedCFI)

const locationsCount = renditionInstance?.book.locations.total
Expand All @@ -130,4 +134,4 @@ const ProgressInfoBar = ()=>{
)
}

export default ProgressInfoBar
export default ProgressInfoBar
2 changes: 1 addition & 1 deletion src/routes/Reader/Reader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ const Home = () =>{
<div onClick={()=>{
dispatch(ToggleProgressMenu())
}} className={styles.percentageContainer}>
{renditionInstance? Math.round(renditionInstance.book.locations.percentageFromCfi(displayedCFI)*100):"0"}%
{displayedCFI && renditionInstance? Math.round(renditionInstance.book.locations.percentageFromCfi(displayedCFI)*100):"0"}%
</div>
<div className={styles.sliderContainer}>
<SliderNavigator/>
Expand Down

0 comments on commit 24a6b4d

Please sign in to comment.