• 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

11.54
/packages/lib-react-components/src/hooks/useUserCollections.js
1
import { collections } from '@zooniverse/panoptes-js'
1✔
2
import useSWR from 'swr'
1!
3

4
import usePanoptesAuthToken from './usePanoptesAuthToken'
2!
5

6
const SWRoptions = {
1✔
7
  revalidateIfStale: true,
8
  revalidateOnMount: true,
9
  revalidateOnFocus: true,
10
  revalidateOnReconnect: true,
11
  refreshInterval: 0
12
}
13

NEW
14
async function fetchUserCollections({ query, token }) {
×
NEW
15
  const authorization = `Bearer ${token}`
×
16

NEW
17
  const response = await collections.get({ authorization, query })
×
18
  
NEW
19
  return response?.body?.collections
×
NEW
20
}
×
21

NEW
22
export default function useUserCollections({ query }) {
×
NEW
23
  const token = usePanoptesAuthToken()
×
NEW
24
  const key = token ? { query, token } : null
×
25

NEW
26
  return useSWR(key, fetchUserCollections, SWRoptions)
×
27
}
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