hypothesis / hypothesis/pdf.js-hypothes.is
[Bug] Hypothes.is not updated after opening new file.
- Dominant language
- JavaScript
- Stars
- 408
- Forks
- 84
- PR merge metrics
- No merged PRs in 30d
Description
There is an upload button for hypothesis's pdf.js view:

However, when i upload a local file via this button, the hypothes.is sidebar remain the content for original file.
I suppose with this bug fixed, it's possible to use hypothes.is on android device without hosting file on server, as i can use a [dummy page](https://via.hypothes.is/https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf) and upload the file, i am actually considering developing a PWA out of it, making the mobile use of hypothes.is easier.
Now, after playing around with the code, it seems the problem can be fixed by modifying `webViewerFileInputChange` in `web/viewer.js` by adding the following at the end of the function
```javascript
function loadHypothesis() {
PDFViewerApplication.initializedPromise.then(() => {
const embedScript = document.createElement('script');
embedScript.src = 'https://hypothes.is/embed.js';
document.body.appendChild(embedScript);
});
}
function unloadHypothesis() {
var appLinkEl =
document.querySelector('link[type="application/annotator+html"]');
appLinkEl.dispatchEvent(new Event('destroy'));
};
function reloadHypothesis(){
unloadHypothesis(); loadHypothesis();
}
reloadHypothesis()
```
I don't know it's the correct way, but Do please consider fix this bug!
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.