0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2025-12-24 20:42:43 +00:00

Attempt to fix issue with saving Google brews.

This commit is contained in:
G.Ambatte
2021-06-28 19:37:06 +12:00
parent 63ea5a3e5f
commit 0cd4b730d7

View File

@@ -135,18 +135,18 @@ const NewPage = createClass({
console.log('saving new brew');
const brew = this.state.brew;
const saveBrew = this.state.brew;
// Split out CSS to Style if CSS codefence exists
if(brew.text.startsWith('```css') && brew.text.indexOf('```\n\n') > 0) {
const index = brew.text.indexOf('```\n\n');
brew.style = `${brew.style ? `${brew.style}\n` : ''}${brew.text.slice(7, index - 1)}`;
brew.text = brew.text.slice(index + 5);
if(saveBrew.text.startsWith('```css') && saveBrew.text.indexOf('```\n\n') > 0) {
const index = saveBrew.text.indexOf('```\n\n');
saveBrew.style = `${saveBrew.style ? `${saveBrew.style}\n` : ''}${saveBrew.text.slice(7, index - 1)}`;
saveBrew.text = saveBrew.text.slice(index + 5);
};
if(this.state.saveGoogle) {
const res = await request
.post('/api/newGoogle/')
.send(brew)
.post('/api/newGoogle')
.send(saveBrew)
.catch((err)=>{
console.log(err.status === 401
? 'Not signed in!'
@@ -158,10 +158,10 @@ const NewPage = createClass({
const brew = res.body;
localStorage.removeItem(BREWKEY);
localStorage.removeItem(STYLEKEY);
window.location = `/edit/${brew.googleId}${brew.editId}`;
window.location = `/edit/${saveBrew.googleId}${saveBrew.editId}`;
} else {
request.post('/api')
.send(brew)
.send(saveBrew)
.end((err, res)=>{
if(err){
this.setState({
@@ -173,7 +173,7 @@ const NewPage = createClass({
const brew = res.body;
localStorage.removeItem(BREWKEY);
localStorage.removeItem(STYLEKEY);
window.location = `/edit/${brew.editId}`;
window.location = `/edit/${saveBrew.editId}`;
});
}
},