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

feat(lists): Cache lists #59

Merged
merged 15 commits into from
May 20, 2024
Merged

feat(lists): Cache lists #59

merged 15 commits into from
May 20, 2024

Conversation

mmcknett
Copy link
Owner

@mmcknett mmcknett commented May 18, 2024

This change adds a listCache field to each account, which it uses for the list field on the time entry form and for the list of lists in the log table beneath the time entry form.

It also:

  • Ensures that it is initialized if it's missing from the database.
  • As a side effect, now we don't have to load all logs for the time entry component, and we can lazy-load the full list of logs when the user clicks a link to show all logs.
image

- Time entry form uses the list cache from Account.
- Factor addLog out of useLogs
Important for testing. This forces the time entry to rely on the list cache for its current list state. When the log table is hidden by default, there isn't anything on the page that loads the full collection of logs, and so if the list cache is empty, nothing will fill it.

The next step is to detect this case automatically and force-update the cache (with the hope that we only have to query all the logs once, to prime the cache).
- When the list cache is absent, we'll load all the docs once and heal it.
- If a list is missing from the cache and we load logs and discover it, we'll add it.
- Whenever we add a log, we'll make sure the list is in the cache.
Now we only use the lists from the logs to ensure that the account list cache is up-to-date.
If the account has been created but there aren't any logs, add the default list to ensure it's there.
Also remove the unnecessary, failing loading spinner test.
Copy link

github-actions bot commented May 18, 2024

Visit the preview URL for this PR (updated for commit d5e20a3):

https://loggr-a3f89--pr59-cache-lists-18hz8zfp.web.app

(expires Sun, 26 May 2024 23:31:47 GMT)

🔥 via Firebase Hosting GitHub Action 🌎

Sign: dcba139c17e47dff84a60c5907b98fbd13d724df

@mmcknett mmcknett merged commit b757a40 into main May 20, 2024
3 checks passed
@mmcknett mmcknett deleted the cache-lists branch May 20, 2024 16:44
@mmcknett mmcknett linked an issue Jun 15, 2024 that may be closed by this pull request
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.

Keep track of known lists
1 participant