Skip to content
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

refactor(ui): optimize state in logs viewer #13046

Merged
merged 2 commits into from
May 14, 2024

Conversation

agilgur5
Copy link
Member

Motivation

simplify & optimize some of the state in the WorkflowLogsViewer component

Modifications

  • only retrieve values from localStorage once, on the initial state set

    • the callback only happens once, while previously it was retrieved on every render but only used on the first
    • also improve the typings a bit by using generics instead of a cast
  • replace the secondary log filter state with a debounce

    • it was giving a 1000ms delay, which is exactly what you can do with a debounce
    • and we already have a debounce func in the utils, so just re-use that

Verification

Screenshot of the filter still working:

Screenshot 2024-05-13 at 3 15 49 PM

- only retrieve values from `localStorage` once, on the initial state set
  - the callback only happens once, while previously it was retrieved on every render but only used on the first
  - also improve the typings a bit by using generics instead of a cast

- replace the secondary log filter state with a debounce
  - it was giving a 1000ms delay, which is exactly what you can do with a debounce
  - and we already have a debounce func in the utils, so just re-use that

Signed-off-by: Anton Gilgur <agilgur5@gmail.com>
Signed-off-by: Anton Gilgur <agilgur5@gmail.com>
@isubasinghe
Copy link
Member

only retrieve values from localStorage once, on the initial state set

Thanks for this, I was just about to ask about what was wrong with the previous. I haven't used react in quite a while.

@agilgur5 agilgur5 enabled auto-merge (squash) May 14, 2024 13:32
@agilgur5 agilgur5 merged commit 5b7d147 into argoproj:main May 14, 2024
16 checks passed
@agilgur5 agilgur5 deleted the refactor-ui-logs-viewer-state branch May 14, 2024 13:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants