Skip to content
This repository has been archived by the owner on Jul 19, 2022. It is now read-only.

Drive perspective changes off of Route changes #282

Merged
merged 1 commit into from
Dec 3, 2021

Conversation

hojberg
Copy link
Member

@hojberg hojberg commented Dec 2, 2021

Overview

Instead of changing perspectives directly and fetching details before changing the URL; first change the URL and then change the Perspective. Ensure that we don't fetch the Perspective when changing URLs to the same Perspective with a different definition and ensure we correctly dedupe WorkspaceItems when we change Perspective.

Fixes: #195

Implementation notes

To support this add a bunch of helper functions:

  • Equality and sameness functions to Reference, Perspective, and HashQualified
  • List-like functions; find, any, and all to WorkspaceItems

With regards to deduping WorkspaceItems, this is needed because when we change Perspective with any open defintions, we migrate the WorkspaceItems to be indexed by Hash instead of FQN, and then when the user subsequently uses the back button to the previous URL that was FQN based, we want to avoid re-fetching and duplicating the same item (their Reference are technically different in that one is Hash based and one is FQN based for the same WorkspaceItem). So as soon as we get the data back from the server and can see that it includes the Hash of an already fetched definition, we dedupe.

Hash as a HashOnly are considered the same
-}
same : Reference -> Reference -> Bool
same a b =
Copy link
Member Author

Choose a reason for hiding this comment

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

This becomes very useful for de-duping

Instead of changing perspectives directly and fetching details before
changing the URL; first change the URL and then change the `Perspective`.
Ensure that we don't fetch the `Perspective` when changing URLs to the same
`Perspective` with a different definition and ensure we correctly dedupe
`WorkspaceItems` when we change `Perspective`.

To support this add a bunch of helper functions:

* Equality and sameness functions to `Reference`, `Perspective`, and
  `HashQualified`
* List-like functions; `find`, `any`, and `all` to `WorkspaceItems`

With regards to deduping `WorkspaceItems`, this is needed because when we
change `Perspective` with any open defintions, we migrate the
`WorkspaceItems` to be indexed by `Hash` instead of `FQN`, and then when
the user subsequently uses the back button to the previous URL that was
`FQN` based, we want to avoid re-fetching and duplicating the same item
(their `Reference` are technically different in that one is `Hash` based
and one is `FQN` based for the same `WorkspaceItem`). So as soon as we
get the data back from the server and can see that it includes the
`Hash` of an already fetched definition, we dedupe.
@hojberg hojberg merged commit 27eb2eb into main Dec 3, 2021
@hojberg hojberg deleted the route-driven-perspective branch December 3, 2021 16:32
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

The Back button should work
1 participant