-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
task/WG-418 - File Listing Component Enhancement and Fixes #337
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, added some thoughts for the future
listingState.path || | ||
(selectedSystem?.id === myDataSystem?.id ? user?.username : ''), | ||
offset: listingState.offset.toString(), | ||
limit: DEFAULT_FILE_LIMIT.toString(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Few suggestions for future improvement:
- offset and limit should be type int, and adjust in the hook query params
- react query has a nice infinite query hook. Used in tandem with
InterSectionObserver
, orreact-intersection-observer
, this would simplify this code a bit with the use of a ref for a node at the bottom of the listing, and a callback to the react-query built-infetchNextPage()
method. If gone that route, you'd be able to get rid of most of theuseState
s in this component
const [selectedSystem, setSelectedSystem] = React.useState<TTapisSystem>( | ||
myDataSystem as TTapisSystem | ||
); | ||
const [hasError, setHasError] = React.useState(false); | ||
const [loadingMoreFiles, setLoadingMoreFiles] = React.useState(false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we use the isLoading
state from the useFiles hook instead?
|
||
if (!dynamicListContainer) return; | ||
|
||
const handleScroll = debounce(() => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nitpick and you don't need to take my advice, but personally I like to avoid lodash. Is there a way to handle the scroll event in this way without the debounce frequency?
{loadingMoreFiles && ( | ||
<p style={{ textAlign: 'center' }}>Loading...</p> | ||
)} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could use a bit more vertical padding here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
Overview:
Adds infinite scrolling for file listing. Fixes bugs related to invalid file selection and empty message.
PR Status:
Related Jira tickets:
Summary of Changes:
Testing Steps:
UI Photos:
Notes:
TODO: