1. 21 Dec, 2020 4 commits
  2. 18 Dec, 2020 7 commits
  3. 17 Dec, 2020 3 commits
    • Robert Knight's avatar
      Defer initial WebSocket connection until profile is fetched · a120b2dd
      Robert Knight authored
      Following https://github.com/hypothesis/client/pull/2837 the
      `SidebarView` component may now be rendered before the profile has been
      fetched. This component contains an effect which triggers the initial
      WebSocket connection. Since the WebSocket reconnects after the profile userid
      changes, this was causing the initial connection to almost immediately
      be disconnected if the user was logged in. Fix this by deferring the initial
      connection until after the profile has been fetched.
      a120b2dd
    • Robert Knight's avatar
      Sync route before waiting for groups and profile to load · 013c82e5
      Robert Knight authored
      Do not wait for groups and profile to load before calling
      `router.sync()` to set the initial route and thereby render the
      appropriate content component.
      
      Historically the main view components assumed that the user profile and
      groups were already loaded before they were rendered, but this is no
      longer the case.
      
      This fixes a brief flash of the sidebar's `TopBar` component inside the
      notebook when it initially loads. It also results in the `Annotations`
      and `Page Notes` tabs appearing immediately in the sidebar rather than
      waiting until the groups list is populated.
      013c82e5
    • Robert Knight's avatar
      Move scroll container measuring into a layout effect · eaaddb46
      Robert Knight authored
      `ThreadList` was measuring the height and scroll offset of the scroll
      container inside the render function instead of a layout effect. As a result
      it could fail if the scroll container is rendered by a parent component
      and its DOM has not yet been created.
      
      This issue was uncovered when trying to change the app to call
      `router.sync()` before waiting for `groups.load()` to complete.
      
      A test expectation had to be changed becaused it turned out that the
      scroll container had the wrong height when it was measured in the
      previous way (it was measured as 0px instead of the expected 350px).
      eaaddb46
  4. 16 Dec, 2020 6 commits
    • Robert Knight's avatar
      Combine `xpath-util` and `xpath` into a single module · e8488b43
      Robert Knight authored
      There was no good reason for the separation between the two any more.
      e8488b43
    • Robert Knight's avatar
      Remove unused range selector generation and anchoring code · b4134e52
      Robert Knight authored
       - The logic for anchoring and generating range selectors provided by `range.js`
         has been replaced in `RangeAnchor`.
       - The normalization of DOM Ranges is no longer required by the rest of
         the code.
      b4134e52
    • Robert Knight's avatar
      Convert `RangeAnchor` to use `TextRange` · 6943f6dd
      Robert Knight authored
      Convert `RangeAnchor` to use `TextRange` and the XPath <-> Node mapping
      functions in xpath.js directly, rather than the `SerializedRange` and
      `NormalizedRange` classes.
      
      This change will mean that all conversion between text positions and
      (text node, offset) points in the client will use the same implementation.
      For `RangeAnchor` selectors this conversion is used for the
      `startOffset` and `endOffset` fields.
      
      The new implementation also avoids modifying the DOM, unlike the
      previous implementation which would sometimes split text nodes. Avoid
      DOM modifications during anchoring opens up the possibility of
      optimizing anchoring by caching text position <-> text node associations.
      6943f6dd
    • Robert Knight's avatar
      Fix menu caret positioning · 0584d344
      Robert Knight authored
      https://github.com/hypothesis/client/pull/2818 inadvertently changed the size
      of the `.menu-toggle__icon` SVG element from 10x10px to 16x16px due to an
      `svg` selector introduced by the `buttons.button--icon-only` mixin
      taking precedence over the `.menu-toggle__icon` selector.
      
      As a result, the caret's vertical position was incorrect and it did not
      remain vertically centered when flipped.
      
      This commit nests the `.menu-toggle__icon` selector inside the parent
      `.menu-toggle` selector to restore the caret icon back to its 10x10
      pixel size.
      0584d344
    • Robert Knight's avatar
      Fix a type checking error related to `getFilterValues` · 7990507f
      Robert Knight authored
      Fix a typechecking error in `useRootThread`.
      
      `@return` has no effect when used above a variable initialized to a
      value that is not an arrow function or function expression. Therefore
      the type was inferred based on the `filterValues` local variable to be
      `{}`. Correct this to `Object.<string,string>` so that it matches up
      with the `ThreadState` type.
      7990507f
    • Robert Knight's avatar
      Infer store module types automatically · 987bcfa5
      Robert Knight authored
      Remove the need to define the type of store created by each module
      manually by adding a `StoreFromModule` helper in `create-store.js` which
      can infer the store type from a store module configuration. Using this
      the type of a store composed from several modules can then be created
      with:
      
      ```
      import fooModule from './modules/foo';
      import barModule from './modules/bar';
      
      // Define type of store returned by `createStore([fooModule, barModule])`
      /** @typedef {StoreType<fooModule> & StoreType<barModule>} AppStore */
      ```
      
      Ideally `createStore` would just infer the type based upon its
      arguments. I haven't worked out how to do that yet. Nevertheless, this
      still removes the need for a lot of manually defined types.
      
      To ensure more useful error messages from TS if a store module's configuration
      has the wrong shape a `storeModule` helper has been added. This wraps
      the configuration for each module to check its shape before the
      individual modules are combined into one type for the store. This helper could
      also perform runtime validation in future.
      
       - Add `StoreFromModule` type in `create-store.js` and several helpers
         to support it
       - Modify each store module to wrap the export in `storeModule` and
         remove any manually defined store types
      987bcfa5
  5. 15 Dec, 2020 1 commit
    • Kyle Keating's avatar
      Small visual improves related to focus / hover styling · 43d1d1d1
      Kyle Keating authored
      - Fix issue where clicking the menu background showed a focus ring
      - Fix issue where buttons in the top-bar were not animating back from hover color
      - Prevent button animation from being applied to focus ring styling (caused issue in safari)
      43d1d1d1
  6. 14 Dec, 2020 12 commits
  7. 11 Dec, 2020 7 commits
    • Robert Knight's avatar
      Improve TextQuoteAnchor tests · f7e9cede
      Robert Knight authored
      For consistency, and because it is useful/straightforward to do, all of the
      `TextQuoteAnchor` tests now mock `matchQuote` but not `TextRange`,
      except for one integration test that is labeled as such.
      f7e9cede
    • Robert Knight's avatar
    • Robert Knight's avatar
      Improve `TextQuoteAnchor.fromRange` test · f307c817
      Robert Knight authored
      Check the properties of the `TextQuoteAnchor` instance have expected
      values.
      f307c817
    • Robert Knight's avatar
      5d43b47b
    • Robert Knight's avatar
      772a73c8
    • Robert Knight's avatar
      Use new quote matching algorithm for quote anchoring · 2a1e14c9
      Robert Knight authored
      Use the new matching algorithm for anchoring text quote selectors. This
      is faster than the existing one when many quote selectors fail to exactly match
      and gives us more insight into and control over the fuzzy matching
      process.
      
       - Use the `matchQuote` function to do find the best match for the quote
         in the text, replacing the `dom-anchor-text-quote` library.
      
         This resolves a problem where the browser could become unresponsive
         for a significant period of time when anchoring large numbers of
         annotations (hundreds) on pages where there have been significant
         changes in the content.
      
         In the "Public" group on http://www.americanyawp.com/text/01-the-new-world/
         for example the client spends a total of ~2.4 seconds running JS in between starting
         the client and anchoring completing compared to ~11 seconds with the
         previous implementation.
      
         The new implementation also provides more control over the degree of
         mismatch between quote selector and document text that is allowed.
         The current settings provide higher recall (larger proportion of
         "correct" approximate matches found) than the previous
         implementation. On http://www.americanyawp.com/text/01-the-new-world/
         for example the number of orphans dropped from 137 to 63.
      
         Finally the new library is also smaller. The minified `annotator.bundle.js`
         size is reduced by 15% (25KB).
      
       - Change `TextQuoteAnchor.fromSelector(...)` to generate the selector
         directly rather than delegating to `dom-anchor-text-quote`. This
         gives us more control over how quote selectors are generated and more
         easily change factors such as the amount of context included.
      2a1e14c9
    • Robert Knight's avatar
      Remove old `useStore` hook · d9e99916
      Robert Knight authored
      All consumers now use the replacement `useStoreProxy` hook.
      d9e99916