• Robert Knight's avatar
    Replace Angular router · 95de09d6
    Robert Knight authored
    Implement a replacement for the Angular JS router which will enable the
    root components of the app to be more easily migrated to Preact in future.
    Since the app only has three routes with very simple parameters, we
    don't yet need a fully-fledged router implementation but can get by with
    some pretty basic URL parsing.
    
     - Introduce a store module which holds the currently active route
       (`null`, "sidebar", "annotation" or "stream") and any parameters of
       that route.
    
       This state replaces the `isSidebar` boolean in the `viewer` module,
       since whether the app is the sidebar can be determined by checking
       the active route name.
    
     - Add a `router` service which handles synchronizing the store route
       with the current URL (via the `sync` method or in response to a
       `popstate` DOM event) or updating the URL and active route in the
       store (via the `navigate` method).
    
     - Modify the `<hypothesis-app>` component to fetch the active route
       from the store and use it to conditionally render the appropriate
       content component. This replaces the Angular router configuration
       that used to be in `src/sidebar/index.js`
    
     - Change the places that used to read or update the current route to
       read the active route and route params from the store (`store.{route,
       routeParams}`) and switch the current route by using the `router` service
       (`router.navigate`)
    
     - Remove the unused angular-route package
    
    Fixes #1878
    95de09d6
stream-search-input-test.js 1.33 KB