Update the browser URL after selecting menu items.

master
Pacman Ghost 3 years ago
parent d81a02317f
commit 189d72725c
  1. 40
      web/src/App.js
  2. 6
      web/src/index.js

@ -92,13 +92,13 @@ export class App extends React.Component
const menu = ( <Menu id="app"> const menu = ( <Menu id="app">
<MenuButton /> <MenuButton />
<MenuList> <MenuList>
<MenuItem id="menu-show-publishers" onSelect={ () => this._showPublishers() } > <MenuItem id="menu-show-publishers" onSelect={ () => this._showPublishers(true) } >
<img src="/images/icons/publisher.png" alt="Show publishers." /> Show publishers <img src="/images/icons/publisher.png" alt="Show publishers." /> Show publishers
</MenuItem> </MenuItem>
<MenuItem id="menu-search-technique" onSelect={ () => this._showTechniqueArticles() } > <MenuItem id="menu-search-technique" onSelect={ () => this._showTechniqueArticles(true) } >
<img src="/images/icons/technique.png" alt="Show technique articles." /> Show technique <img src="/images/icons/technique.png" alt="Show technique articles." /> Show technique
</MenuItem> </MenuItem>
<MenuItem id="menu-search-tips" onSelect={ () => this._showTipsArticles() } > <MenuItem id="menu-search-tips" onSelect={ () => this._showTipsArticles(true) } >
<img src="/images/icons/tips.png" alt="Show tip articles." /> Show tips <img src="/images/icons/tips.png" alt="Show tip articles." /> Show tips
</MenuItem> </MenuItem>
<div className="divider" /> <div className="divider" />
@ -258,20 +258,26 @@ export class App extends React.Component
args = {} ; args = {} ;
this._doSearch( url, args, onDone ) ; this._doSearch( url, args, onDone ) ;
} }
_showPublishers() { _showPublishers( pushState ) {
this.runSpecialSearch( "/search/publishers", null, this.runSpecialSearch( "/search/publishers", null, () => {
() => { this.setWindowTitle( "All publishers" ) } this.setWindowTitle( "All publishers" ) ;
) if ( pushState )
} window.history.pushState( null, document.title, "/publishers"+window.location.search ) ;
_showTechniqueArticles() { } )
this.runSpecialSearch( "/search/tag/technique", {randomize:1}, }
() => { this.setWindowTitle( "Technique" ) } _showTechniqueArticles( pushState ) {
) this.runSpecialSearch( "/search/tag/technique", {randomize:1}, () => {
} this.setWindowTitle( "Technique" ) ;
_showTipsArticles() { if ( pushState )
this.runSpecialSearch( "/search/tag/tips", {randomize:1}, window.history.pushState( null, document.title, "/technique"+window.location.search ) ;
() => { this.setWindowTitle( "Tips" ) } } )
) }
_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 ) { prependSearchResult( sr ) {

@ -13,13 +13,13 @@ ReactDOM.render(
<BrowserRouter> <BrowserRouter>
<Switch> <Switch>
<Route path="/publishers" render={ (props) => <App {...props} type="publishers" key="publishers" <Route path="/publishers" render={ (props) => <App {...props} type="publishers" key="publishers"
doSearch = { () => gAppRef._showPublishers() } doSearch = { () => gAppRef._showPublishers(false) }
/> } /> /> } />
<Route path="/technique" render={ (props) => <App {...props} type="technique" key="technique" <Route path="/technique" render={ (props) => <App {...props} type="technique" key="technique"
doSearch = { () => gAppRef._showTechniqueArticles() } doSearch = { () => gAppRef._showTechniqueArticles(false) }
/> } /> /> } />
<Route path="/tips" render={ (props) => <App {...props} type="tips" key="tips" <Route path="/tips" render={ (props) => <App {...props} type="tips" key="tips"
doSearch = { () => gAppRef._showTipsArticles() } doSearch = { () => gAppRef._showTipsArticles(false) }
/> } /> /> } />
<Route path="/publisher/:publId" render={ (props) => <App {...props} type="publisher" key={"publ:"+props.match.params.publId} <Route path="/publisher/:publId" render={ (props) => <App {...props} type="publisher" key={"publ:"+props.match.params.publId}
doSearch = { () => gAppRef.runSpecialSearch( "/search/publisher/"+gAppRef.props.match.params.publId, null, doSearch = { () => gAppRef.runSpecialSearch( "/search/publisher/"+gAppRef.props.match.params.publId, null,

Loading…
Cancel
Save