Skip to content

[Bug] Hypothes.is not updated after opening new file. #28

@StructSeeker

Description

@StructSeeker

There is an upload button for hypothesis's pdf.js view:
Image
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 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

    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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions