Skip to content

Commit

Permalink
fix anchor navigation
Browse files Browse the repository at this point in the history
  • Loading branch information
rafapaezbas committed Mar 7, 2024
1 parent 9c1d16c commit 8f70812
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion building-blocks/hyperdrive.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Notable features include:

* Uses Hyperbee internally for storing file metadata
* Major API simplification. Instead of mirroring POSIX APIs, the new API better captures the core requirements of P2P file transfer.
* Auxiliary tools, [`localdrive`](./helpers/localdrive.md) and [`mirrordrive`](./helpers/mirrordrive.md), that streamline import/export flows and make it easy to mirror drives to and from the local filesystem.
* Auxiliary tools, [`localdrive`](../helpers/localdrive.md) and [`mirrordrive`](../helpers/mirrordrive.md), that streamline import/export flows and make it easy to mirror drives to and from the local filesystem.

> [GitHub (Hyperdrive)](https://github.com/holepunchto/hyperdrive)
Expand Down
14 changes: 8 additions & 6 deletions lib/app-router.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,17 @@ customElements.define('app-router', class AppRouter extends HTMLElement {
super()
this.routes = {}
this.page = null
this.anchor = null
}

unload () {
for (const element of Object.values(this.routes)) element?.unload && element.unload()
}

async load (pathname = '/', opts = {}) {
if (this.page === pathname) return
if (this.page === pathname && this.anchor === opts.anchor) return
this.page = pathname
this.anchor = opts.anchor
for (const [route, element] of Object.entries(this.routes)) {
if (pathname.startsWith(route)) {
const page = pathname.slice(route.length) || '/'
Expand Down Expand Up @@ -73,11 +75,11 @@ customElements.define('app-router', class AppRouter extends HTMLElement {
const page = '/' + (Pear.config.linkData || '')
console.log('load', page)
this.load(page).catch(console.error)
Pear.wakeups(({ data }) => {
Pear.Window.self.focus({ steal: true }).catch(console.error)
const page = '/' + (data || '')
this.load(page).catch(console.error)
})
// Pear.wakeups(({ data }) => {
// Pear.Window.self.focus({ steal: true }).catch(console.error)
// const page = '/' + (data || '')
// this.load(page).catch(console.error)
// })
})
}
})

0 comments on commit 8f70812

Please sign in to comment.