futurepress / epubjs-rn

EpubJS React Native Example
Other
270 stars 150 forks source link

BUG: start.cfi does not update location #63

Open valinaga opened 7 years ago

valinaga commented 7 years ago

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 commented 7 years ago

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 commented 7 years ago

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.

imarem commented 7 years ago

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

valinaga commented 7 years ago

@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 })

imarem commented 7 years ago

Hi @valinaga

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

valinaga commented 7 years ago

@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.

imarem commented 6 years ago

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 commented 6 years ago

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

fchasen commented 6 years ago

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

valinaga commented 6 years ago

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 commented 6 years ago

@fchasen hi,

any updates on this one? thanks!