fragment: remove non-contextual fragments on start

Signed-off-by: Varun Patil <radialapps@gmail.com>
pull/888/head
Varun Patil 2023-10-24 13:03:01 -07:00
parent cf3b782cec
commit f44ac76c58
1 changed files with 10 additions and 0 deletions

View File

@ -190,6 +190,16 @@ export const fragment = {
};
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),
});
}
/**
* Trigger when route changes; notify listeners of popped fragments.
* @param to Switching to this route