From 9e7e646296b9e73a8f09ce9385468951715713da Mon Sep 17 00:00:00 2001 From: "G.Ambatte" Date: Wed, 19 Jul 2023 20:34:10 +1200 Subject: [PATCH] Add username to save key --- client/homebrew/pages/accountPage/accountPage.jsx | 9 +++++---- client/homebrew/pages/newPage/newPage.jsx | 4 +++- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/client/homebrew/pages/accountPage/accountPage.jsx b/client/homebrew/pages/accountPage/accountPage.jsx index 1d236f7ad..b19b0f47a 100644 --- a/client/homebrew/pages/accountPage/accountPage.jsx +++ b/client/homebrew/pages/accountPage/accountPage.jsx @@ -16,7 +16,7 @@ const HelpNavItem = require('../../navbar/help.navitem.jsx'); const NaturalCritIcon = require('naturalcrit/svg/naturalcrit.svg.jsx'); -const saveLocationKey = 'HOMEBREWERY-DEFAULT-SAVE-LOCATION'; +let SAVEKEY = ''; const AccountPage = createClass({ displayName : 'AccountPage', @@ -32,8 +32,9 @@ const AccountPage = createClass({ }; }, componentDidMount : function(){ - if(!this.state.saveLocation) { - const saveLocation = window.localStorage.getItem(saveLocationKey) || ''; + if(!this.state.saveLocation && this.props.uiItems.username) { + SAVEKEY = `HOMEBREWERY-DEFAULT-SAVE-LOCATION-${this.props.uiItems.username}`; + const saveLocation = window.localStorage.getItem(SAVEKEY) || ''; if(saveLocation == '') { // TO DO: Implement logic to determine the appropriate location given current state console.log(this.state.uiItems); @@ -46,7 +47,7 @@ const AccountPage = createClass({ makeActive : function(newSelection){ if(this.state.saveLocation == newSelection) return; - window.localStorage.setItem(saveLocationKey, newSelection); + window.localStorage.setItem(SAVEKEY, newSelection); this.setState({ saveLocation : newSelection }); diff --git a/client/homebrew/pages/newPage/newPage.jsx b/client/homebrew/pages/newPage/newPage.jsx index 923c4d61e..73e83960c 100644 --- a/client/homebrew/pages/newPage/newPage.jsx +++ b/client/homebrew/pages/newPage/newPage.jsx @@ -23,7 +23,7 @@ const { DEFAULT_BREW } = require('../../../../server/brewDefaults.js'); const BREWKEY = 'homebrewery-new'; const STYLEKEY = 'homebrewery-new-style'; const METAKEY = 'homebrewery-new-meta'; -const SAVEKEY = 'HOMEBREWERY-DEFAULT-SAVE-LOCATION'; +let SAVEKEY; const NewPage = createClass({ @@ -55,6 +55,8 @@ const NewPage = createClass({ const brewStorage = localStorage.getItem(BREWKEY); const styleStorage = localStorage.getItem(STYLEKEY); const metaStorage = JSON.parse(localStorage.getItem(METAKEY)); + + SAVEKEY = `HOMEBREWERY-DEFAULT-SAVE-LOCATION-${global.account.username}`; const saveStorage = localStorage.getItem(SAVEKEY); brew.text = brewStorage ?? brew.text;