0
0
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:
Trevor Buckner
2021-03-04 22:58:40 -05:00
parent 3358094319
commit 5b242989da
3 changed files with 1 additions and 4 deletions

View File

@@ -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>

View File

@@ -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 }
});

View File

@@ -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);