diff --git a/client/homebrew/pages/accountPage/accountPage.jsx b/client/homebrew/pages/accountPage/accountPage.jsx index 644ab13d8..77f246a8b 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

@@ -51,12 +50,16 @@ 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.googleId && +

+ 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 4afd0e8c7..8a3e4c12a 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,9 +352,9 @@ 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); } @@ -363,18 +362,19 @@ app.get('/account', asyncHandler(async (req, res, next)=>{ } const query = { authors: req.account.username, googleId: { $exists: false } }; - const brews = await HomebrewModel.find(query, 'id') + const mongoCount = await HomebrewModel.countDocuments(query) .catch((err)=>{ + mongoCount = 0; console.log(err); }); 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, + googleId : Boolean(req.account.googleId), + authCheck : Boolean(req.account.googleId && auth.credentials.access_token), + mongoCount : mongoCount, + googleCount : googleCount?.length }; }