Skip to content

Conversation

@drewvolz
Copy link
Member

@drewvolz drewvolz commented Jun 20, 2022

✨What this is

  • A use of filter toolbar on story categories to give a little more depth to the news list.
  • Part of the larger initiative to add filtering to more lists.

🗒️ Todo

  • make the tests pass
  • a cleaner dependency array for buildFilters via e5f56e7
  • need to fix a few typings (spec.selected)
  • figure out what filter's apply: { key: should reference

📸 Screenshots

filtering menu none empty
filtering menu none empty

🎥 Demo

drewvolz added 3 commits June 20, 2022 12:13
* generate categories from a set of categories
* build filters as a list of OR'd filters

remaining:
* need to fix a few typings (spec.selected)
* a cleaner dependency array for buildFilters
@drewvolz drewvolz requested review from hawkrives and rye as code owners June 20, 2022 19:48
@drewvolz
Copy link
Member Author

drewvolz commented Jul 2, 2022

Anything more to do here? This is ready for another review.

Copy link
Member

@hawkrives hawkrives left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

… from a month ago

@drewvolz drewvolz requested a review from hawkrives August 18, 2022 02:34
@drewvolz drewvolz requested a review from hawkrives August 19, 2022 00:06
@hawkrives
Copy link
Member

How sure are you that memoize doesn't use an unbounded cache? It'd be bad if we tried to fix one perf issue only to eat all available ram

@drewvolz
Copy link
Member Author

drewvolz commented Aug 19, 2022

I'm not sure about the bounding/unbounding sizes of memoize's cache.

Memoize's cache would be unbounded, yes.

Although we we have this pattern elsewhere in the codebase for large lists: course catalog and student orgs.

let memoizedDoSearch = memoize(doSearch)
// lodash supports this; the types do not.
memoizedDoSearch.cache = new WeakMap()
export const CourseResultsList = (props: Props): JSX.Element => {
let navigation = useNavigation()
let {
filters,
query,
courses,
applyFilters,
onPopoverDismiss,
contentContainerStyle,
style,
filtersLoaded,
} = props
// be sure to lowercase the query before calling doSearch, so that the memoization
// doesn't break when nothing's changed except case.
query = query?.toLowerCase()
let results = memoizedDoSearch({query, filters, courses, applyFilters})

const splitToArray = memoize((str: string) => words(deburr(str.toLowerCase())))
const orgToArray = memoize((term: StudentOrgType) =>
Array.from(
new Set([
...splitToArray(term.name),
...splitToArray(term.category),
...splitToArray(term.description),
]),
),
)

@hawkrives
Copy link
Member

Ok! :shipit:

@drewvolz
Copy link
Member Author

@rye thoughts? I think we've now got this cleaned up!

@drewvolz drewvolz merged commit 866e366 into master Aug 22, 2022
@drewvolz drewvolz deleted the drew/news-filters branch August 22, 2022 23:47
@drewvolz drewvolz restored the drew/news-filters branch August 24, 2022 02:18
@drewvolz drewvolz deleted the drew/news-filters branch August 24, 2022 02:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants