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

Tally should update on add/remove, not all events #2051

Open
frzyc opened this issue Apr 30, 2024 · 2 comments
Open

Tally should update on add/remove, not all events #2051

frzyc opened this issue Apr 30, 2024 · 2 comments
Assignees
Labels
good first issue Issue with low complexity and relatively easy solution for those looking to raise an easy PR

Comments

@frzyc
Copy link
Owner

frzyc commented Apr 30, 2024

This is more of a nit to how we do this in GO, I think these gets rerendered every time we change an artifact/relic, but it should rerender every time an artifact/relic is added/removed (since it only display the total).

It make sense to use the DataManagerCallback.reason string, and check against 'remove' | 'new'. Would also make sense to store total as a state instead of useForceUpdate, so when total is set as the same value again, it doesnt trigger a revalue.

Originally posted by @frzyc in #2025 (comment)

Psudocode:

const [tally, setTally] = useState(database.relics.length)
useEffect(()=>databse.relics.followAny((_,reason)=>['remove','new'].includes(reason) && setTally(database.relics.length),[database])

Example implementation #2061

@frzyc frzyc added the good first issue Issue with low complexity and relatively easy solution for those looking to raise an easy PR label Apr 30, 2024
@AlexVascon
Copy link

@frzyc I'm happy to look at this for you if that's ok?

@frzyc
Copy link
Owner Author

frzyc commented Apr 30, 2024

Thanks, let me know if you have any questions

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Issue with low complexity and relatively easy solution for those looking to raise an easy PR
Projects
None yet
Development

No branches or pull requests

2 participants