1. 22 Apr, 2021 15 commits
    • Robert Knight's avatar
      Simplify a check for `undefined` · 4471182d
      Robert Knight authored
      Checking `typeof <var>` is only needed when the variable may not exist
      (eg. some browser global).
      4471182d
    • Robert Knight's avatar
      Extract `getGrantToken` helper · bb742fa1
      Robert Knight authored
      Put the logic for getting the grant token in one place so it can be
      better documented.
      
      Also remove or simplify some other code slightly upon a second reading.
      bb742fa1
    • Robert Knight's avatar
      Improve the wording of a comment · 0355bc53
      Robert Knight authored
      A call to `refreshAccessToken` is not the only way that the token can
      change while waiting for a response to the `POST /api/token` endpoint.
      0355bc53
    • Robert Knight's avatar
      Rename `tokenGetter` => `getAccessToken` · 2e3cc6c9
      Robert Knight authored
      The previous name was a vestige from the days of Angular 1.x in the
      client. Use a clearer name instead.
      2e3cc6c9
    • Robert Knight's avatar
      Refactor `tokenGetter` method · 593bb287
      Robert Knight authored
      Refactor and better document the `tokenGetter` method to make it easier
      to follow:
      
       - Split some sub-steps out into helper methods
       - Add comments to call out the high-levels steps in the flow
      593bb287
    • Robert Knight's avatar
      Extract `exchangeAuthCodeForToken` method · 06e6bd1a
      Robert Knight authored
      Extract a helper from a long async method to shorten it.
      06e6bd1a
    • Robert Knight's avatar
      Simplify control flow in `AuthService` using async/await · edb9c257
      Robert Knight authored
      Make several functions/methods in the service easier to follow by
      refactoring promise chains to async/await.
      edb9c257
    • Robert Knight's avatar
      Add a couple of missing `FrameSyncService` tests · e3d67074
      Robert Knight authored
       - Add tests for `scrollToAnnotation`
      
       - Add test for failed `getDocumentInfo` request to host page
      e3d67074
    • Robert Knight's avatar
      Convert `frameSync` service to ES class · f4d8b73b
      Robert Knight authored
      Convert the `frameSync` service to an ES class and rewrite the
      documentation that explains what the service does.
      
      Some internal `frameSync` methods are still set up in the constructor
      with closures. These can be converted to ES class methods in later
      refactoring.
      
      Part of https://github.com/hypothesis/client/issues/3298.
      f4d8b73b
    • Eduardo Sanz García's avatar
      Make listener passive · 53344d6e
      Eduardo Sanz García authored
      Chrome 89 printed the following warnings on the console:
      
      ```
      shadow-root.js:67 [Violation] Added non-passive event listener to a scroll-blocking 'touchstart' event. Consider marking event handler as 'passive' to make the page more responsive
      ```
      
      See also: https://www.chromestatus.com/feature/5745543795965952
      
      I have removed a listener that it isn't no longer needed, because it is wrapped in
      a shadow DOM that already stop the bubbling up of the event.
      
      Another 'touchstart' listener had the potential to slow down scrolling
      on the host page on mobile devices. To avoid that we have made listener
      passive.
      
      These changes remove the warnings without affecting the current
      behaviour of the application.
      53344d6e
    • Robert Knight's avatar
      Retry `/api/links` fetch if it fails · 121416fe
      Robert Knight authored
      Move the logic for retrying API metadata fetching into the `getJSON`
      helper function so that it is used both when fetching the API index
      (`/api`) and the service links (`/api/links`).
      121416fe
    • Robert Knight's avatar
    • Robert Knight's avatar
      843f684e
    • Robert Knight's avatar
      Rename property containing unused params in `replaceURLParams` return value · 68f3ef05
      Robert Knight authored
      Rename property from `params` to `unusedParams` for clarity.
      68f3ef05
    • Robert Knight's avatar
      Reimplement service URL fetching · 6b0c776f
      Robert Knight authored
      Change the way that links pointing into the Hypothesis service (eg. for
      tags, users, account settings etc.) are fetched and generated. The new
      implementation better matches patterns used elsewhere in the application
      and ensures that UI components displaying these links re-render if the
      `/api/links` response is received after the component is initially
      rendered.
      
       - Move the logic for rendering the URL templates from the `serviceUrl`
         service into a selector in the `links` store module. Components then
         render links using `store.getLink(...)`. This ensures use of the existing
         mechanism that re-renders components when relevant store data changes.
      
       - Convert the `serviceUrl` service to an ES class
      
       - Move the logic for fetching URL templates from the `/api/links`
         endpoint into an `init` method of the `ServiceURLService` service.
         This matches the convention used by several other services.
      
       - Remove unused `serviceUrl` dependency from `groups` service
      6b0c776f
  2. 20 Apr, 2021 11 commits
  3. 19 Apr, 2021 9 commits
  4. 16 Apr, 2021 5 commits