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.
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.
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 thePerspective
when changing URLs to the samePerspective
with a different definition and ensure we correctly dedupeWorkspaceItems
when we changePerspective
.Fixes: https://github.com/unisonweb/codebase-ui/issues/195
Implementation notes
To support this add a bunch of helper functions:
Reference
,Perspective
, andHashQualified
find
,any
, andall
toWorkspaceItems
With regards to deduping
WorkspaceItems
, this is needed because when we changePerspective
with any open defintions, we migrate theWorkspaceItems
to be indexed byHash
instead ofFQN
, and then when the user subsequently uses the back button to the previous URL that wasFQN
based, we want to avoid re-fetching and duplicating the same item (theirReference
are technically different in that one isHash
based and one isFQN
based for the sameWorkspaceItem
). So as soon as we get the data back from the server and can see that it includes theHash
of an already fetched definition, we dedupe.