Skip to content
This repository was archived by the owner on Sep 30, 2024. It is now read-only.

chore(svelte): Refactor infinity query implementation#63824

Merged
fkling merged 6 commits into
mainfrom
fkling/sk/refactor-inifity-query
Jul 16, 2024
Merged

chore(svelte): Refactor infinity query implementation#63824
fkling merged 6 commits into
mainfrom
fkling/sk/refactor-inifity-query

Conversation

@fkling

@fkling fkling commented Jul 15, 2024

Copy link
Copy Markdown
Contributor

In preparation for other work, this commit substantially refactors the "infinity query" store implementation. The internals have been changed completely which allows us to simplify its public API.

  • Simpler configuration. Query responses and next variables are now processed and merged in a single function.
  • Restoration support. So far pages/components had to implement restoring the state of an infinity store on their own. Now the restoration strategy is part of the configuration. Pages/components only have to get an opaque snapshot via store.capture() and restore it via store.restore(snapshot).
  • More predictable state. It wasn't always obvious if the store content stale data e.g. during restoring data. Now data will only be set when the data is 'fresh'.
  • Smarter 'incremental restoration' strategy. This strategy makes multiple requests to restore the previous state. It makes multiple requests because normally requests are cached and there this is fast. When the data is not cached though there is a noticable delay due to waterfall requests. Now we use a simple heuristic to determine whether or not GraqhQL data might be cached. If not we make a single request to restore the state.

For review I suggest to turn whitespace changes off.

Test plan

Manual testing, unit tests.

@fkling fkling self-assigned this Jul 15, 2024
@cla-bot cla-bot Bot added the cla-signed label Jul 15, 2024
In preparation for other work, this commit substantially refactors the
"infinity query" store implementation. The internals have been changed
completely which allows us to simplify its public API.

- Simpler configuration. Query responses and next variables are now
  processed and merged in a single function.
- Restoration support. So far pages/components had to implement
  restoring the state of an infinity store on their own. Now the
  restoration strategy is part of the configuration. Pages/components
  only have to get an opaque snapshot via `store.capture()` and restore
  it via `store.restore(snapshot)`.
- More predictable state. It wasn't always obvious if the store content
  stale data e.g. during restoring data. Now `data` will only be set
  when the data is 'fresh'.
- Smarter 'incremental restoration' strategy. This strategy makes
  multiple requests to restore the previous state. It makes multiple
  requests because normally requests are cached and there this is fast.
  When the data is not cached though there is a noticable delay due to
  waterfall requests.
  Now we use a simple heuristic to determine whether or not GraqhQL data
  might be cached. If not we make a single request to restore the state.
@fkling fkling force-pushed the fkling/sk/refactor-inifity-query branch from ea434d9 to ff807c1 Compare July 15, 2024 11:58
Comment on lines 226 to 229

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

By not relying on implicit accumulated state we have more control over the current state.

Comment on lines -101 to -106
$: if (!!commitHistoryQuery) {
// Reset commit history when the query observable changes. Without
// this we are showing the commit history of the previously selected
// file/folder until the new commit history is loaded.
commitHistory = null
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This "just works" now.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nice!

@camdencheek camdencheek left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is great! This seems to address a big chunk of feedback I had after using InfinityQuery for the new references panel

Comment on lines -38 to -39
// Wait until DOM was update before updating the scroll position
await tick()

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Oh, haha. I just asked about this in my other PR.

Comment on lines -101 to -106
$: if (!!commitHistoryQuery) {
// Reset commit history when the query observable changes. Without
// this we are showing the commit history of the previously selected
// file/folder until the new commit history is loaded.
commitHistory = null
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nice!

@fkling fkling merged commit 23616fa into main Jul 16, 2024
@fkling fkling deleted the fkling/sk/refactor-inifity-query branch July 16, 2024 04:51
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants