mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2025-12-24 18:32:41 +00:00
Handle cached text
The NEW page saves to the browser LocalStorage the current text in case the user goes to a different page before saving. The new "import" function wasn't working since it was being overwritten by any cached values if they existed from an earlier "new" page.
This commit is contained in:
@@ -9,7 +9,6 @@ const EditPage = require('./pages/editPage/editPage.jsx');
|
||||
const UserPage = require('./pages/userPage/userPage.jsx');
|
||||
const SharePage = require('./pages/sharePage/sharePage.jsx');
|
||||
const NewPage = require('./pages/newPage/newPage.jsx');
|
||||
//const ImportPage = require('./pages/importPage/importPage.jsx');
|
||||
//const ErrorPage = require('./pages/errorPage/errorPage.jsx');
|
||||
const PrintPage = require('./pages/printPage/printPage.jsx');
|
||||
|
||||
@@ -49,7 +48,6 @@ const Homebrew = createClass({
|
||||
<Route path='/user/:username' component={(routeProps)=><UserPage username={routeProps.match.params.username} brews={this.props.brews} />}/>
|
||||
<Route path='/print/:id' component={(routeProps)=><PrintPage brew={this.props.brew} query={queryString.parse(routeProps.location.search)} /> } />
|
||||
<Route path='/print' exact component={(routeProps)=><PrintPage query={queryString.parse(routeProps.location.search)} /> } />
|
||||
//<Route path='/new' exact component={NewPage}/>
|
||||
<Route path='/changelog' exact component={()=><SharePage brew={{ title: 'Changelog', text: this.props.changelog }} />}/>
|
||||
<Route path='/' component={()=><HomePage welcomeText={this.props.welcomeText}/>}/>
|
||||
</Switch>
|
||||
|
||||
@@ -61,7 +61,7 @@ const NewPage = createClass({
|
||||
|
||||
componentDidMount : function() {
|
||||
const storage = localStorage.getItem(KEY);
|
||||
if(storage){
|
||||
if(!this.props.brew.text && storage){
|
||||
this.setState({
|
||||
brew : { text: storage }
|
||||
});
|
||||
|
||||
@@ -146,7 +146,6 @@ app.get('/edit/:id', (req, res, next)=>{
|
||||
|
||||
//New Page
|
||||
app.get('/new/:id', (req, res, next)=>{
|
||||
res.header('Cache-Control', 'no-cache, no-store'); //reload the latest saved brew when pressing back button, not the cached version before save.
|
||||
if(req.params.id.length > 12) {
|
||||
const googleId = req.params.id.slice(0, -12);
|
||||
const shareId = req.params.id.slice(-12);
|
||||
|
||||
Reference in New Issue
Block a user