Skip to content

Delay loading of percentageFromCfi until displayedCFI is ready.#49

Merged
btpf merged 1 commit into
btpf:mainfrom
Neulus:main
Jul 14, 2024
Merged

Delay loading of percentageFromCfi until displayedCFI is ready.#49
btpf merged 1 commit into
btpf:mainfrom
Neulus:main

Conversation

@Neulus

@Neulus Neulus commented Jul 5, 2024

Copy link
Copy Markdown
Contributor

When loading a .txt file, I observed that percentageFromCfi is invoked with displayedCFI before displayedCFI is fully initialized. This premature loading can cause issues similar to those reported in #47.

Changes

  • Added a check to ensure displayedCFI is loaded before invoking percentageFromCfi.

@btpf

btpf commented Jul 14, 2024

Copy link
Copy Markdown
Owner

Nice job tracking it down.

I think a small change I would prefer is just setting the currentPercentage to 0 if the displayedCFI is not ready.

24a6b4d#diff-5fbaa34ea6def579f01b427ae5834cbdd8811adc65b5fa7cd82520e075eabb7eR110-R114
to just

  // wait until displayedCFI is loaded
  const currentPercentage = displayedCFI ? renditionInstance?.book.locations.percentageFromCfi(displayedCFI):0

Ill merge this in and make the changes. Thanks!

@btpf btpf merged commit d3885dc into btpf:main Jul 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants