• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

zooniverse / front-end-monorepo / 16531866204

25 Jul 2025 09:23PM UTC coverage: 77.439% (-0.5%) from 77.896%
16531866204

push

github

web-flow
lib-react-components: Add FavoritesIconButton component and useUserCollections hook (#6958)

* Add initial FavoritesIconButton component

* Add usePanoptesAuthToken and useUserCollections

* Refactor SubjectTalkPage with connector and FavoritesIconButton

* Add FavoritesIconButtonContainer with useUserCollections

* Add addSubjects and removeSubjects mutations

* Add create favorite

* Refactor addSubjectsToCollection with options arg

* Add FavoritesIconButton tests

* Refactor props passed from SubjectTalkPageConnector to FavoritesIconButtonContainer

* Add comment for refactoring with subjects that include favorite boolean

* Add documentation for usePanoptesAuthToken and useUserCollections hooks

* Refactor collections updates with mutate

* Update FavoritesIconButton README

* Add FavoritesIconButton to CHANGELOG

* Remove unused SubjectTalkPageConnector export

* Refactor SubjectTalkPageConnector useStores

* Update SubjectTalkViewer with optional chaining

Co-authored-by: Delilah C. <23665803+goplayoutside3@users.noreply.github.com>

* Refactor FavoritesIconButton with useEffect per checked property

* Remove mutate from FavoritesIconButtonContainer

* use swr mutate to modify icon checked or not-checked (#6975)

---------

Co-authored-by: Delilah C. <23665803+goplayoutside3@users.noreply.github.com>

11348 of 17140 branches covered (66.21%)

Branch coverage included in aggregate %.

63 of 137 new or added lines in 13 files covered. (45.99%)

17570 of 20203 relevant lines covered (86.97%)

398.95 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

36.07
/packages/lib-react-components/src/hooks/usePanoptesAuthToken.js
1
import auth from 'panoptes-client/lib/auth'
1✔
2
import { useState } from 'react'
132!
3

4
const isBrowser = typeof window !== 'undefined'
1✔
5

6
let defaultToken
7
/*
8
  See comments in https://github.com/zooniverse/front-end-monorepo/pull/6345
9
  Top-level await in modules has been supported in Node
10
  and in all browsers since 2021. However, ES modules are still
11
  not supported in the monorepo. An immediately-invoked async
12
  function is a workaround when top-level await is not supported.
13
  https://v8.dev/features/top-level-await
14
*/
15
(async function getDefaultToken() {
7✔
16
  defaultToken = null
1!
17
  if (isBrowser) {
1✔
18
    await auth.checkCurrent()
1✔
19
    defaultToken = await auth.checkBearerToken()
1✔
20
  }
21
})()
22

23
export default function usePanoptesAuthToken() {
NEW
24
  const [token, setToken] = useState(defaultToken)
×
25

NEW
26
  async function fetchPanoptesAuthToken() {
×
NEW
27
    await auth.checkCurrent()
×
NEW
28
    const newToken = await auth.checkBearerToken()
×
NEW
29
    if (newToken !== token) {
×
NEW
30
      setToken(newToken)
×
NEW
31
    }
×
NEW
32
  }
×
33

NEW
34
  fetchPanoptesAuthToken()
×
NEW
35
  return token
×
36
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc