epubjs-rn icon indicating copy to clipboard operation
epubjs-rn copied to clipboard

BUG: start.cfi does not update location

Open valinaga opened this issue 7 years ago • 11 comments

Hi,

For the latest version, 0.0.103 it seems that updating location with cfi does not work anymore. A location: start.cfi does not trigger a onLocationChange and does not render the page correctly. The location and href from start seems to trigger the onLocationChange but only href works correctly. Most of the times location keeps the spinning on and doesn't render the page. Since href is too broad, it is not a working alternative. Any idea on how to fix these back?

valinaga avatar Sep 11 '17 07:09 valinaga

Generated locations are stored locally using AsyncStorage using a book.key(). But it appears that the key() method always return the same value for iOS. I didn't try it yet in android, but this.package.metadata most likely will be the same for one app. I updated in Epub.js the method loadLocations() from: var key = this.book.key()+"-locations"; to var key = this.book.key(this.book.url.filename)+"-locations"; Now the key will be different for different books filenames. Hope this help whoever was trying to figure out why for different books setting location was buggy.

valinaga avatar Sep 11 '17 08:09 valinaga

After the update above, the issue still persists. I suspected that since the locations were messed up the cfi and location won't be found. But the issue is more profound. The location still trigger onLocationChange at the beginning of the book and cfi does not trigger onLocationChange at all.

valinaga avatar Sep 11 '17 09:09 valinaga

Hi @valinaga

Wich version of epubjs do you use? It seems to be related to version 0.3.51, I downgrade to 0.3.49 and start.cfi changed correctly.

I hope it helps

imarem avatar Sep 13 '17 11:09 imarem

@imarem 0.0.103 came with 0.3.49. It used to work but not anymore now. The issue is when you try to setState({ location: start.cfi })

valinaga avatar Sep 13 '17 11:09 valinaga

Hi @valinaga

I could reproduce the error you commented, but it only happens to me in some epubs. the start.cfi doesn't change.

imarem avatar Sep 14 '17 10:09 imarem

@imarem Yes, and I noticed that the cfi does not clearly identify the current page. Using location: start.cfi does not always go the the same page the start was retrieved through onLocationChange. Any idea? BTW, now I'm on 0.0.106 with 0.3.51 sometimes the cfi works, sometimes it doesn't.

valinaga avatar Sep 14 '17 12:09 valinaga

Hi @fchasen

Have you detected the error that @valinaga comments? It only happens to me in any epubs, not everyone has this error. Do you know if it can be epub theme or is it an error in the library?

Thanks in advance

imarem avatar Sep 19 '17 08:09 imarem

Hi again,

@valinaga : After passing the epubs that failed me, by the validator http://validator.idpf.org/, and fix the errors that contained. The start.cfi is updated correctly!

seems to indicate that these is for the errors in the epubs, not in the plugin, but I can't assure it.

I hope it helps

imarem avatar Sep 19 '17 10:09 imarem

Do you have a book you can share with me? Would help track the issue, which is likely in epubjs not in RN.

fchasen avatar Sep 21 '17 03:09 fchasen

https://www.dropbox.com/sh/ej5p93xof9cpxo7/AACsoLwz0RzDui8w_v8a7Wqia?dl=1 For some reasons the dropbox change the extension to zip. Please just change the extension but do not unzip the file. It's an epub.

valinaga avatar Sep 21 '17 06:09 valinaga

@fchasen hi,

any updates on this one? thanks!

valinaga avatar Oct 24 '17 16:10 valinaga