Skip to content

Commit

Permalink
experimental logs
Browse files Browse the repository at this point in the history
  • Loading branch information
AlecAivazis committed Oct 18, 2023
1 parent 448b5f7 commit da7040f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/canary.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,6 @@ jobs:
run: |
pnpm changeset version --snapshot
pnpm run build
pnpm changeset publish --no-git-tag --snapshot --tag canary
pnpm changeset publish --no-git-tag --snapshot --tag experimental
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
18 changes: 15 additions & 3 deletions packages/houdini-react/src/runtime/routing/Router.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ export function Router({
return initialURL || window.location.pathname
})

console.log('currentURL', current)

// find the matching page for the current route
const [page, variables] = find_match(manifest, current)

Expand Down Expand Up @@ -169,6 +171,7 @@ function usePageData({

// if there is a pending request and we were asked to load, don't do anything
if (ssr_signals.has(id)) {
console.log('using ssr signal instead of loading the query on the client', id)
return ssr_signals.get(id)!
}

Expand Down Expand Up @@ -246,6 +249,7 @@ function usePageData({
})
}
console.log('clearing ssr signal', artifactName)
// trigger the signal
window.__houdini__nav_caches__.ssr_signals.get(artifactName).resolve()
window.__houdini__nav_caches__.ssr_signals.delete(artifactName)
Expand Down Expand Up @@ -273,6 +277,7 @@ function usePageData({
last_variables.has(targetPage.id) &&
!deepEquals(last_variables.get(targetPage.id), variables)
) {
console.log('variables have changed. clearing data cache')
data_cache.clear()
}

Expand Down Expand Up @@ -530,6 +535,7 @@ function useLinkNavigation({ goto }: { goto: (url: string) => void }) {

const link = findAnchor(e.target as HTMLElement, document.body)
// its a link we want to handle so don't navigate like normal
console.log('link', link)

// we only want to capture a "normal click" ie something that indicates a route transition
// in the current tab
Expand All @@ -550,28 +556,34 @@ function useLinkNavigation({ goto }: { goto: (url: string) => void }) {
!e.defaultPrevented
)
) {
console.log('link', link)
return
}

// we need to figure out the target url by looking at the href attribute
const target = link.attributes.getNamedItem('href')?.value
console.log("target link'", target)
// make sure its a link we recognize
if (!target || !target.startsWith('/')) {
return
}

console.log("processing link'", target)

// its a link we want to handle so don't navigate like normal
e.preventDefault()
e.stopPropagation()

// go to the next route as a low priority update
startTransition(() => {
goto(target)
})
// startTransition(() => {
// goto(target)
// })
}

console.log('registering click handler')
window.addEventListener('click', onClick)
return () => {
console.log('unregistering click handler')
window.removeEventListener('click', onClick!)
}
}, [])
Expand Down

0 comments on commit da7040f

Please sign in to comment.