From 0867b142da2d5207ef53e682a5bf120ea3850e57 Mon Sep 17 00:00:00 2001 From: Charlie Humphreys Date: Thu, 27 Oct 2022 21:44:26 -0500 Subject: [PATCH 01/17] update getBrew usages to not fetch google brew during updates --- server/homebrew.api.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/server/homebrew.api.js b/server/homebrew.api.js index 293e8f873..586466364 100644 --- a/server/homebrew.api.js +++ b/server/homebrew.api.js @@ -27,7 +27,7 @@ const getId = (req)=>{ return { id, googleId }; }; -const getBrew = (accessType)=>{ +const getBrew = (accessType, fetchGoogle = true)=>{ // Create middleware with the accessType passed in as part of the scope return async (req, res, next)=>{ // Get relevant IDs for the brew @@ -45,7 +45,7 @@ const getBrew = (accessType)=>{ stub = stub?.toObject(); // If there is a google id, try to find the google brew - if(googleId || stub?.googleId) { + if(fetchGoogle && (googleId || stub?.googleId)) { let googleError; const googleBrew = await GoogleActions.getGoogleBrew(googleId || stub?.googleId, id, accessType) .catch((err)=>{ @@ -327,8 +327,8 @@ const deleteBrew = async (req, res, next)=>{ }; router.post('/api', asyncHandler(newBrew)); -router.put('/api/:id', asyncHandler(getBrew('edit')), asyncHandler(updateBrew)); -router.put('/api/update/:id', asyncHandler(getBrew('edit')), asyncHandler(updateBrew)); +router.put('/api/:id', asyncHandler(getBrew('edit', false)), asyncHandler(updateBrew)); +router.put('/api/update/:id', asyncHandler(getBrew('edit', false)), asyncHandler(updateBrew)); router.delete('/api/:id', asyncHandler(deleteBrew)); router.get('/api/remove/:id', asyncHandler(deleteBrew)); From 2c6779bb1c893b910c47ed76c0d5b42b64786a4a Mon Sep 17 00:00:00 2001 From: Charlie Humphreys Date: Wed, 16 Nov 2022 22:28:00 -0600 Subject: [PATCH 02/17] adjust getBrew to check authorship, change update method to not perform a get --- server/homebrew.api.js | 44 +++++++++++++++++++++++------------------- 1 file changed, 24 insertions(+), 20 deletions(-) diff --git a/server/homebrew.api.js b/server/homebrew.api.js index 586466364..44b604bbc 100644 --- a/server/homebrew.api.js +++ b/server/homebrew.api.js @@ -43,6 +43,9 @@ const getBrew = (accessType, fetchGoogle = true)=>{ } }); stub = stub?.toObject(); + if(stub?.authors && !stub?.authors.includes(req.account.username)) { + throw 'Current logged in user does not have access to this brew.'; + } // If there is a google id, try to find the google brew if(fetchGoogle && (googleId || stub?.googleId)) { @@ -59,14 +62,14 @@ const getBrew = (accessType, fetchGoogle = true)=>{ } // If after all of that we still don't have a brew, throw an exception - if(!stub) { + if(!stub && fetchGoogle) { throw 'Brew not found in Homebrewery database or Google Drive'; } - if(typeof stub.tags === 'string') { + if(typeof stub?.tags === 'string') { stub.tags = []; } - req.brew = stub; + req.brew = stub || {}; next(); }; @@ -234,30 +237,31 @@ const updateBrew = async (req, res)=>{ if(req.account) { brew.authors = _.uniq(_.concat(brew.authors, req.account.username)); } - - // Fetch the brew from the database again (if it existed there to begin with), and assign the existing brew to it - brew = _.assign(await HomebrewModel.findOne({ _id: brew._id }), brew); - - if(!brew.markModified) { - // If it wasn't in the database, create a new db brew - brew = new HomebrewModel(brew); + // we need the tag type change in both getBrew and here to handle the case where we don't have a stub on which to perform the modification + if(typeof brew.tags === 'string') { + brew.tags = []; } - brew.markModified('authors'); - brew.markModified('systems'); - - // Save the database brew - const saved = await brew.save() - .catch((err)=>{ - console.error(err); - res.status(err.status || 500).send(err.message || 'Unable to save brew to Homebrewery database'); - }); + // define a function to catch our save errors + const saveError = (err)=>{ + console.error(err); + res.status(err.status || 500).send(err.message || 'Unable to save brew to Homebrewery database'); + }; + let saved; + if(!brew._id) { + // if the brew does not have a stub id, create and save it, then write the new value back to the brew. + saved = await new HomebrewModel(brew).save().catch(saveError); + brew = saved.toObject(); + } else { + // if the brew does have a stub id, update it using the stub id as the key. + saved = await HomebrewModel.updateOne({ _id: brew._id }, brew).catch(saveError); + } if(!saved) return; // Call and wait for afterSave to complete const after = await afterSave(); if(!after) return; - res.status(200).send(saved); + res.status(200).send(brew); }; const deleteGoogleBrew = async (account, id, editId, res)=>{ From f9711de634b6af758a8e18a003e2eab4058b63fb Mon Sep 17 00:00:00 2001 From: Charlie Humphreys Date: Wed, 16 Nov 2022 22:32:50 -0600 Subject: [PATCH 03/17] add elvis for the possibility that the save failed --- server/homebrew.api.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/homebrew.api.js b/server/homebrew.api.js index 44b604bbc..563926f01 100644 --- a/server/homebrew.api.js +++ b/server/homebrew.api.js @@ -251,7 +251,7 @@ const updateBrew = async (req, res)=>{ if(!brew._id) { // if the brew does not have a stub id, create and save it, then write the new value back to the brew. saved = await new HomebrewModel(brew).save().catch(saveError); - brew = saved.toObject(); + brew = saved?.toObject(); } else { // if the brew does have a stub id, update it using the stub id as the key. saved = await HomebrewModel.updateOne({ _id: brew._id }, brew).catch(saveError); From 2e305d56361398422a8044bf2ca642e6822ebf50 Mon Sep 17 00:00:00 2001 From: Charlie Humphreys Date: Wed, 16 Nov 2022 22:37:59 -0600 Subject: [PATCH 04/17] remove authorship piece from this PR --- server/homebrew.api.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/server/homebrew.api.js b/server/homebrew.api.js index 563926f01..ec8e438fa 100644 --- a/server/homebrew.api.js +++ b/server/homebrew.api.js @@ -43,9 +43,6 @@ const getBrew = (accessType, fetchGoogle = true)=>{ } }); stub = stub?.toObject(); - if(stub?.authors && !stub?.authors.includes(req.account.username)) { - throw 'Current logged in user does not have access to this brew.'; - } // If there is a google id, try to find the google brew if(fetchGoogle && (googleId || stub?.googleId)) { From 837708fc0c9f900a116ff9284441819fc041e964 Mon Sep 17 00:00:00 2001 From: Charlie Humphreys Date: Wed, 16 Nov 2022 22:39:06 -0600 Subject: [PATCH 05/17] prevent changes to brews from non-authors --- server/homebrew.api.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/server/homebrew.api.js b/server/homebrew.api.js index ec8e438fa..563926f01 100644 --- a/server/homebrew.api.js +++ b/server/homebrew.api.js @@ -43,6 +43,9 @@ const getBrew = (accessType, fetchGoogle = true)=>{ } }); stub = stub?.toObject(); + if(stub?.authors && !stub?.authors.includes(req.account.username)) { + throw 'Current logged in user does not have access to this brew.'; + } // If there is a google id, try to find the google brew if(fetchGoogle && (googleId || stub?.googleId)) { From f26e3d6cd1a53f6075f3835f44204c2a340d7c62 Mon Sep 17 00:00:00 2001 From: Charlie Humphreys Date: Fri, 18 Nov 2022 17:53:47 -0600 Subject: [PATCH 06/17] remove tags from google brew fetch --- server/googleActions.js | 1 - server/homebrew.api.js | 4 ---- 2 files changed, 5 deletions(-) diff --git a/server/googleActions.js b/server/googleActions.js index 4ccf7a1dd..8a11a73ac 100644 --- a/server/googleActions.js +++ b/server/googleActions.js @@ -249,7 +249,6 @@ const GoogleActions = { text : file.data, description : obj.data.description, - tags : obj.data.properties.tags ? obj.data.properties.tags : '', systems : obj.data.properties.systems ? obj.data.properties.systems.split(',') : [], authors : [], published : obj.data.properties.published ? obj.data.properties.published == 'true' : false, diff --git a/server/homebrew.api.js b/server/homebrew.api.js index ec8e438fa..484ca8bb5 100644 --- a/server/homebrew.api.js +++ b/server/homebrew.api.js @@ -234,10 +234,6 @@ const updateBrew = async (req, res)=>{ if(req.account) { brew.authors = _.uniq(_.concat(brew.authors, req.account.username)); } - // we need the tag type change in both getBrew and here to handle the case where we don't have a stub on which to perform the modification - if(typeof brew.tags === 'string') { - brew.tags = []; - } // define a function to catch our save errors const saveError = (err)=>{ From fec1766e269925a06f5e3761c02307d2cd179653 Mon Sep 17 00:00:00 2001 From: Charlie Humphreys Date: Mon, 21 Nov 2022 16:21:36 -0600 Subject: [PATCH 07/17] switch fetchGoogle to stubOnly --- server/homebrew.api.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/server/homebrew.api.js b/server/homebrew.api.js index 484ca8bb5..b46bbd1ab 100644 --- a/server/homebrew.api.js +++ b/server/homebrew.api.js @@ -27,7 +27,7 @@ const getId = (req)=>{ return { id, googleId }; }; -const getBrew = (accessType, fetchGoogle = true)=>{ +const getBrew = (accessType, stubOnly = false)=>{ // Create middleware with the accessType passed in as part of the scope return async (req, res, next)=>{ // Get relevant IDs for the brew @@ -45,7 +45,7 @@ const getBrew = (accessType, fetchGoogle = true)=>{ stub = stub?.toObject(); // If there is a google id, try to find the google brew - if(fetchGoogle && (googleId || stub?.googleId)) { + if(!stubOnly && (googleId || stub?.googleId)) { let googleError; const googleBrew = await GoogleActions.getGoogleBrew(googleId || stub?.googleId, id, accessType) .catch((err)=>{ @@ -59,7 +59,7 @@ const getBrew = (accessType, fetchGoogle = true)=>{ } // If after all of that we still don't have a brew, throw an exception - if(!stub && fetchGoogle) { + if(!stub && !stubOnly) { throw 'Brew not found in Homebrewery database or Google Drive'; } @@ -324,8 +324,8 @@ const deleteBrew = async (req, res, next)=>{ }; router.post('/api', asyncHandler(newBrew)); -router.put('/api/:id', asyncHandler(getBrew('edit', false)), asyncHandler(updateBrew)); -router.put('/api/update/:id', asyncHandler(getBrew('edit', false)), asyncHandler(updateBrew)); +router.put('/api/:id', asyncHandler(getBrew('edit', true)), asyncHandler(updateBrew)); +router.put('/api/update/:id', asyncHandler(getBrew('edit', true)), asyncHandler(updateBrew)); router.delete('/api/:id', asyncHandler(deleteBrew)); router.get('/api/remove/:id', asyncHandler(deleteBrew)); From 89e6bada56cb74ca3b910660e6646126e2e355d9 Mon Sep 17 00:00:00 2001 From: "G.Ambatte" Date: Tue, 29 Nov 2022 10:26:44 +1300 Subject: [PATCH 08/17] Add link to instructions to refresh Google creds --- client/homebrew/pages/accountPage/accountPage.jsx | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/client/homebrew/pages/accountPage/accountPage.jsx b/client/homebrew/pages/accountPage/accountPage.jsx index 644ab13d8..0b7369949 100644 --- a/client/homebrew/pages/accountPage/accountPage.jsx +++ b/client/homebrew/pages/accountPage/accountPage.jsx @@ -42,7 +42,6 @@ const AccountPage = createClass({ }, renderUiItems : function() { - // console.log(this.props.uiItems); return <>

Account Information

@@ -56,7 +55,11 @@ const AccountPage = createClass({

Google Information

Linked to Google: {this.props.uiItems.googleId ? 'YES' : 'NO'}

- {this.props.uiItems.googleId ?

Brews on Google Drive: {this.props.uiItems.fileCount || '-'}

: '' } + {this.props.uiItems.googleId && +

+ Brews on Google Drive: {this.props.uiItems.fileCount != '-' ? this.props.uiItems.fileCount : <>Unable to retrieve files - follow these steps to renew your Google credentials.} +

+ }
; }, From 99019be152304f7c4ea49e119bb326ff9fb06ca7 Mon Sep 17 00:00:00 2001 From: Charlie Humphreys Date: Mon, 5 Dec 2022 21:00:44 -0600 Subject: [PATCH 09/17] switch updateOne to findOneAndUpdate and return the saved instead of the brew passed in --- server/homebrew.api.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/server/homebrew.api.js b/server/homebrew.api.js index b46bbd1ab..57b009b8c 100644 --- a/server/homebrew.api.js +++ b/server/homebrew.api.js @@ -247,14 +247,16 @@ const updateBrew = async (req, res)=>{ brew = saved?.toObject(); } else { // if the brew does have a stub id, update it using the stub id as the key. - saved = await HomebrewModel.updateOne({ _id: brew._id }, brew).catch(saveError); + saved = await HomebrewModel.findOneAndUpdate({ _id: brew._id }, brew, { + returnOriginal : false + }).catch(saveError); } if(!saved) return; // Call and wait for afterSave to complete const after = await afterSave(); if(!after) return; - res.status(200).send(brew); + res.status(200).send(saved); }; const deleteGoogleBrew = async (account, id, editId, res)=>{ From 4c629772cc7d09e4f0950f67029529e55638b48b Mon Sep 17 00:00:00 2001 From: Charlie Humphreys Date: Mon, 5 Dec 2022 22:11:24 -0600 Subject: [PATCH 10/17] add a check for the accessType when editing a document --- server/homebrew.api.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/homebrew.api.js b/server/homebrew.api.js index 563926f01..e5d304b69 100644 --- a/server/homebrew.api.js +++ b/server/homebrew.api.js @@ -43,7 +43,7 @@ const getBrew = (accessType, fetchGoogle = true)=>{ } }); stub = stub?.toObject(); - if(stub?.authors && !stub?.authors.includes(req.account.username)) { + if(accessType === 'edit' && stub?.authors && !stub?.authors.includes(req.account.username)) { throw 'Current logged in user does not have access to this brew.'; } From 6b8db74a2b51a17cbbac378ca99c0429f05f7aa3 Mon Sep 17 00:00:00 2001 From: Charlie Humphreys Date: Mon, 5 Dec 2022 22:31:56 -0600 Subject: [PATCH 11/17] add authors length check and account elvis operator --- server/homebrew.api.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/homebrew.api.js b/server/homebrew.api.js index e5d304b69..393c9793d 100644 --- a/server/homebrew.api.js +++ b/server/homebrew.api.js @@ -43,7 +43,7 @@ const getBrew = (accessType, fetchGoogle = true)=>{ } }); stub = stub?.toObject(); - if(accessType === 'edit' && stub?.authors && !stub?.authors.includes(req.account.username)) { + if(accessType === 'edit' && stub?.authors?.length > 0 && !stub?.authors.includes(req.account?.username)) { throw 'Current logged in user does not have access to this brew.'; } From d0a1ef9571ac7eeee4716f310f19d4205840adcb Mon Sep 17 00:00:00 2001 From: "G.Ambatte" Date: Fri, 9 Dec 2022 18:35:17 +1300 Subject: [PATCH 12/17] Change to aggregate query, rename variables --- .../pages/accountPage/accountPage.jsx | 4 +-- server/app.js | 36 ++++++++++++------- 2 files changed, 25 insertions(+), 15 deletions(-) diff --git a/client/homebrew/pages/accountPage/accountPage.jsx b/client/homebrew/pages/accountPage/accountPage.jsx index 0b7369949..95d77e9bb 100644 --- a/client/homebrew/pages/accountPage/accountPage.jsx +++ b/client/homebrew/pages/accountPage/accountPage.jsx @@ -50,14 +50,14 @@ const AccountPage = createClass({

Homebrewery Information

-

Brews on Homebrewery: {this.props.uiItems.mongoCount || '-'}

+

Brews on Homebrewery: {this.props.uiItems.mongoCount}

Google Information

Linked to Google: {this.props.uiItems.googleId ? 'YES' : 'NO'}

{this.props.uiItems.googleId &&

- Brews on Google Drive: {this.props.uiItems.fileCount != '-' ? this.props.uiItems.fileCount : <>Unable to retrieve files - follow these steps to renew your Google credentials.} + Brews on Google Drive: {this.props.uiItems.googleCount ? this.props.uiItems.googleCount : <>Unable to retrieve files - follow these steps to renew your Google credentials.}

}
diff --git a/server/app.js b/server/app.js index 4afd0e8c7..6d732429c 100644 --- a/server/app.js +++ b/server/app.js @@ -280,7 +280,6 @@ app.get('/edit/:id', asyncHandler(getBrew('edit')), (req, res, next)=>{ title : req.brew.title || 'Untitled Brew', description : req.brew.description || 'No description.', image : req.brew.thumbnail || defaultMetaTags.image, - type : 'article' }; @@ -341,7 +340,7 @@ app.get('/account', asyncHandler(async (req, res, next)=>{ data.title = 'Account Information Page'; let auth; - let files; + let googleCount = []; if(req.account) { if(req.account.googleId) { try { @@ -353,28 +352,39 @@ app.get('/account', asyncHandler(async (req, res, next)=>{ } if(auth.credentials.access_token) { try { - files = await GoogleActions.listGoogleBrews(auth); + googleCount = await GoogleActions.listGoogleBrews(auth); } catch (e) { - files = undefined; + googleCount = undefined; console.log('List Google files failed!'); console.log(e); } } } - const query = { authors: req.account.username, googleId: { $exists: false } }; - const brews = await HomebrewModel.find(query, 'id') + const aggregateQuery =[{ + '$match' : { + 'googleId' : { + '$exists' : false + }, + 'authors' : req.account.username + } + }, { + '$count' : 'total' + }]; + const mongoCount = []; + mongoCount.push(...await HomebrewModel.aggregate(aggregateQuery) .catch((err)=>{ console.log(err); - }); + })); + mongoCount.push({ total: 0 }); data.uiItems = { - username : req.account.username, - issued : req.account.issued, - mongoCount : brews.length, - googleId : Boolean(req.account.googleId), - authCheck : Boolean(req.account.googleId && auth.credentials.access_token), - fileCount : files?.length || '-' + username : req.account.username, + issued : req.account.issued, + mongoCount : mongoCount[0]?.total.toString(), + googleId : Boolean(req.account.googleId), + authCheck : Boolean(req.account.googleId && auth.credentials.access_token), + googleCount : googleCount?.length.toString() || null }; } From b72acd9e59a1cfd3944bd7b58e625b4723fa0854 Mon Sep 17 00:00:00 2001 From: Trevor Buckner Date: Sat, 10 Dec 2022 13:31:57 -0500 Subject: [PATCH 13/17] cleanup --- .../pages/accountPage/accountPage.jsx | 2 +- server/app.js | 22 +++++-------------- 2 files changed, 7 insertions(+), 17 deletions(-) diff --git a/client/homebrew/pages/accountPage/accountPage.jsx b/client/homebrew/pages/accountPage/accountPage.jsx index 95d77e9bb..77f246a8b 100644 --- a/client/homebrew/pages/accountPage/accountPage.jsx +++ b/client/homebrew/pages/accountPage/accountPage.jsx @@ -57,7 +57,7 @@ const AccountPage = createClass({

Linked to Google: {this.props.uiItems.googleId ? 'YES' : 'NO'}

{this.props.uiItems.googleId &&

- Brews on Google Drive: {this.props.uiItems.googleCount ? this.props.uiItems.googleCount : <>Unable to retrieve files - follow these steps to renew your Google credentials.} + Brews on Google Drive: {this.props.uiItems.googleCount ?? <>Unable to retrieve files - follow these steps to renew your Google credentials.}

} diff --git a/server/app.js b/server/app.js index 6d732429c..8a3e4c12a 100644 --- a/server/app.js +++ b/server/app.js @@ -361,30 +361,20 @@ app.get('/account', asyncHandler(async (req, res, next)=>{ } } - const aggregateQuery =[{ - '$match' : { - 'googleId' : { - '$exists' : false - }, - 'authors' : req.account.username - } - }, { - '$count' : 'total' - }]; - const mongoCount = []; - mongoCount.push(...await HomebrewModel.aggregate(aggregateQuery) + const query = { authors: req.account.username, googleId: { $exists: false } }; + const mongoCount = await HomebrewModel.countDocuments(query) .catch((err)=>{ + mongoCount = 0; console.log(err); - })); - mongoCount.push({ total: 0 }); + }); data.uiItems = { username : req.account.username, issued : req.account.issued, - mongoCount : mongoCount[0]?.total.toString(), googleId : Boolean(req.account.googleId), authCheck : Boolean(req.account.googleId && auth.credentials.access_token), - googleCount : googleCount?.length.toString() || null + mongoCount : mongoCount, + googleCount : googleCount?.length }; } From a9a9804517a334061ed72d8e31481b74814fee69 Mon Sep 17 00:00:00 2001 From: Trevor Buckner Date: Sat, 10 Dec 2022 14:15:09 -0500 Subject: [PATCH 14/17] v3.4.2 --- changelog.md | 17 +++++++++++++++++ package-lock.json | 4 ++-- package.json | 2 +- 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/changelog.md b/changelog.md index 89b8a1976..8e6502227 100644 --- a/changelog.md +++ b/changelog.md @@ -44,6 +44,23 @@ pre { ## changelog For a full record of development, visit our [Github Page](https://github.com/naturalcrit/homebrewery). +### Saturday 10/12/2022 - v3.4.2 +{{taskList + +##### Jeddai + +* [x] Fix broken tags editor + +* [x] Reduce server load to fix some saving issues + +Fixes issues [#2322](https://github.com/naturalcrit/homebrewery/issues/2322) + +##### Gazook + +* [x] Account page help link for Google Drive errors + +Fixes issues [#2520](https://github.com/naturalcrit/homebrewery/issues/2520) +}} ### Monday 05/12/2022 - v3.4.1 {{taskList diff --git a/package-lock.json b/package-lock.json index 37db3aa82..b2499d137 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "homebrewery", - "version": "3.4.1", + "version": "3.4.2", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "homebrewery", - "version": "3.4.1", + "version": "3.4.2", "hasInstallScript": true, "license": "MIT", "dependencies": { diff --git a/package.json b/package.json index 3838a5b66..a6a25de1e 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "homebrewery", "description": "Create authentic looking D&D homebrews using only markdown", - "version": "3.4.1", + "version": "3.4.2", "engines": { "node": "16.11.x" }, From 263471bcbb83f41057e1c2b40258fe851d0e08b6 Mon Sep 17 00:00:00 2001 From: Trevor Buckner Date: Sat, 10 Dec 2022 18:03:16 -0500 Subject: [PATCH 15/17] Fix changelog typo --- changelog.md | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/changelog.md b/changelog.md index 8e6502227..452705f00 100644 --- a/changelog.md +++ b/changelog.md @@ -7,6 +7,11 @@ h5 { margin-left: 0px; } +.page .taskList { + display:block; + break-inside:auto; +} + .taskList li input { list-style-type : none; margin-left : -0.52cm; @@ -35,10 +40,20 @@ pre { margin-top : 0.1cm; } +.page ul + h5 { + margin-top: 0.25cm; +} + +.page p + h5 { + margin-top: 0.25cm; +} + .page .openSans { font-family: 'Open Sans'; font-size: 0.9em; } + + ``` ## changelog @@ -55,7 +70,7 @@ For a full record of development, visit our [Github Page](https://github.com/nat Fixes issues [#2322](https://github.com/naturalcrit/homebrewery/issues/2322) -##### Gazook +##### G-Ambatte * [x] Account page help link for Google Drive errors @@ -159,12 +174,7 @@ Fixes issues [#2135](https://github.com/naturalcrit/homebrewery/issues/2135) * [x] Fix brew settings being lost on first save Fixes issues [#2427](https://github.com/naturalcrit/homebrewery/issues/2427) -}} -\column - - -{{taskList ##### Gazook: * [x] Several updates to bug reporting and error popups @@ -214,6 +224,10 @@ Fixes issues [#2317](https://github.com/naturalcrit/homebrewery/issues/2317), [ Fixes issues: [#1797](https://github.com/naturalcrit/homebrewery/issues/1797), [#2315](https://github.com/naturalcrit/homebrewery/issues/2315), [#2326](https://github.com/naturalcrit/homebrewery/issues/2326), [#2328](https://github.com/naturalcrit/homebrewery/issues/2328) }} + + +\page + ### Wednesday 31/08/2022 - v3.2.1 {{taskList @@ -240,8 +254,6 @@ Fixes issues [#2317](https://github.com/naturalcrit/homebrewery/issues/2317), [ Fixes issues: [#2301](https://github.com/naturalcrit/homebrewery/issues/2301), [#2303](https://github.com/naturalcrit/homebrewery/issues/2303), [#2121](https://github.com/naturalcrit/homebrewery/issues/2121) }} -\page - ### Saturday 27/08/2022 - v3.2.0 {{taskList From 326c28a11d476c5b942e83ed5ae2fdd76130f088 Mon Sep 17 00:00:00 2001 From: Trevor Buckner Date: Mon, 12 Dec 2022 09:59:04 -0500 Subject: [PATCH 16/17] Change findOneAndUpdate to FindOne and Save Setting an object property to `undefined` should tell Mongoose to remove that property (for example, remove the googleId from a brew). That doesn't seem to work with `findOneAndUpdate` however; the `undefined` property remains after the update. Switching back to `save()` to make this work again. --- server/homebrew.api.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/server/homebrew.api.js b/server/homebrew.api.js index 57b009b8c..572321ef2 100644 --- a/server/homebrew.api.js +++ b/server/homebrew.api.js @@ -247,9 +247,10 @@ const updateBrew = async (req, res)=>{ brew = saved?.toObject(); } else { // if the brew does have a stub id, update it using the stub id as the key. - saved = await HomebrewModel.findOneAndUpdate({ _id: brew._id }, brew, { - returnOriginal : false - }).catch(saveError); + brew = _.assign(await HomebrewModel.findOne({ _id: brew._id }), brew); + saved = await brew.save() + .catch(saveError); + }); } if(!saved) return; // Call and wait for afterSave to complete From 747c976a142604bc395d0def3b5bd9a7d0a9fd8b Mon Sep 17 00:00:00 2001 From: Trevor Buckner Date: Mon, 12 Dec 2022 10:19:49 -0500 Subject: [PATCH 17/17] typo --- server/homebrew.api.js | 1 - 1 file changed, 1 deletion(-) diff --git a/server/homebrew.api.js b/server/homebrew.api.js index 572321ef2..b36f1d4fa 100644 --- a/server/homebrew.api.js +++ b/server/homebrew.api.js @@ -250,7 +250,6 @@ const updateBrew = async (req, res)=>{ brew = _.assign(await HomebrewModel.findOne({ _id: brew._id }), brew); saved = await brew.save() .catch(saveError); - }); } if(!saved) return; // Call and wait for afterSave to complete