Skip to content

Commit

Permalink
fragment: prevent redundant navigation
Browse files Browse the repository at this point in the history
Signed-off-by: Varun Patil <radialapps@gmail.com>
  • Loading branch information
pulsejet committed Oct 25, 2023
1 parent e4e1345 commit 1f7602c
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/services/utils/fragment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,11 +193,14 @@ document.addEventListener('DOMContentLoaded', () => {
// Only contextual fragments should be present on page load
if (fragment.list.length) {
const contextual = fragment.list.filter((frag) => frag.type === FragmentType.viewer);
_m.router.replace({
path: _m.route.path,
query: _m.route.query,
hash: encodeFragment(contextual),
});
const hash = encodeFragment(contextual);
if (hash !== _m.route.hash) {
_m.router.replace({
path: _m.route.path,
query: _m.route.query,
hash: hash,
});
}
}

/**
Expand Down

0 comments on commit 1f7602c

Please sign in to comment.