From 189d72725cd9d68a5bf4fd6e936d41b4b3356aa3 Mon Sep 17 00:00:00 2001 From: Taka Date: Wed, 17 Nov 2021 22:05:13 +1100 Subject: [PATCH] Update the browser URL after selecting menu items. --- web/src/App.js | 40 +++++++++++++++++++++++----------------- web/src/index.js | 6 +++--- 2 files changed, 26 insertions(+), 20 deletions(-) diff --git a/web/src/App.js b/web/src/App.js index cb9dc9f..ebc0689 100644 --- a/web/src/App.js +++ b/web/src/App.js @@ -92,13 +92,13 @@ export class App extends React.Component const menu = ( - this._showPublishers() } > + this._showPublishers(true) } > Show publishers. Show publishers - this._showTechniqueArticles() } > + this._showTechniqueArticles(true) } > Show technique articles. Show technique - this._showTipsArticles() } > + this._showTipsArticles(true) } > Show tip articles. Show tips
@@ -258,20 +258,26 @@ export class App extends React.Component args = {} ; this._doSearch( url, args, onDone ) ; } - _showPublishers() { - this.runSpecialSearch( "/search/publishers", null, - () => { this.setWindowTitle( "All publishers" ) } - ) - } - _showTechniqueArticles() { - this.runSpecialSearch( "/search/tag/technique", {randomize:1}, - () => { this.setWindowTitle( "Technique" ) } - ) - } - _showTipsArticles() { - this.runSpecialSearch( "/search/tag/tips", {randomize:1}, - () => { this.setWindowTitle( "Tips" ) } - ) + _showPublishers( pushState ) { + this.runSpecialSearch( "/search/publishers", null, () => { + this.setWindowTitle( "All publishers" ) ; + if ( pushState ) + window.history.pushState( null, document.title, "/publishers"+window.location.search ) ; + } ) + } + _showTechniqueArticles( pushState ) { + this.runSpecialSearch( "/search/tag/technique", {randomize:1}, () => { + this.setWindowTitle( "Technique" ) ; + if ( pushState ) + window.history.pushState( null, document.title, "/technique"+window.location.search ) ; + } ) + } + _showTipsArticles( pushState ) { + this.runSpecialSearch( "/search/tag/tips", {randomize:1}, () => { + this.setWindowTitle( "Tips" ) ; + if ( pushState ) + window.history.pushState( null, document.title, "/tips"+window.location.search ) ; + } ) } prependSearchResult( sr ) { diff --git a/web/src/index.js b/web/src/index.js index 67482e1..a541b31 100644 --- a/web/src/index.js +++ b/web/src/index.js @@ -13,13 +13,13 @@ ReactDOM.render( gAppRef._showPublishers() } + doSearch = { () => gAppRef._showPublishers(false) } /> } /> gAppRef._showTechniqueArticles() } + doSearch = { () => gAppRef._showTechniqueArticles(false) } /> } /> gAppRef._showTipsArticles() } + doSearch = { () => gAppRef._showTipsArticles(false) } /> } /> gAppRef.runSpecialSearch( "/search/publisher/"+gAppRef.props.match.params.publId, null,