Skip to content

Commit

Permalink
Separate pathname and search query for history driver sink input
Browse files Browse the repository at this point in the history
Required as of @cycle/history v7.2.0, see cyclejs/cyclejs#909
  • Loading branch information
shesek committed Oct 15, 2019
1 parent 54c0dbd commit 68da931
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
5 changes: 3 additions & 2 deletions client/src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -339,10 +339,11 @@ export default function main({ DOM, HTTP, route, storage, scanner: scan$, search

// Route navigation sink
, navto$ = O.merge(
searchResult$.filter(Boolean).map(path => ({ type: 'push', pathname: path }))
searchResult$.filter(Boolean).map(result => ({ type: 'push', ...result }))
, byHeight$.map(hash => ({ type: 'replace', pathname: `/block/${hash}` }))
, updateQuery$.map(([ pathname, qs ]) => ({ type: 'replace', pathname: pathname+qs, state: { noRouting: true } }))
, pushedtx$.map(txid => ({ type: 'push', pathname: `/tx/${txid}` }))
// XXX: replace still uses a single string with the search query (https://github.com/cyclejs/cyclejs/pull/890#issuecomment-542413707)
, updateQuery$.map(([ pathname, qs ]) => ({ type: 'replace', pathname: pathname+qs, state: { noRouting: true } }))
)

dbg({ goHome$, goBlock$, goTx$, togTx$, page$, lang$, vdom$
Expand Down
6 changes: 4 additions & 2 deletions client/src/driver/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,14 @@ export default apiBase => {
.then(r => r.ok ? r.text : Promise.reject('invalid reply for block height'))
.then(blockhash => request(`${apiBase}/block/${blockhash}/txid/${matches[3]}`))
.then(r => r.ok ? r.text : Promise.reject('invalid reply for block txid'))
.then(txid => `/tx/${txid}?output:${matches[4]}`)
.then(txid => ({ pathname: `/tx/${txid}`, search: `?output:${matches[4]}` }))
.catch(_ => null)

// @XXX the tx/block/addr resource will be fetched again later for display,
// which is somewhat wasteful but not terribly so due to browser caching.

: null
).share()
)
.map(result => typeof result == 'string' ? { pathname: result } : result)
.share()
}

0 comments on commit 68da931

Please sign in to comment.