0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2026-01-14 02:02:51 +00:00

Add username to save key

This commit is contained in:
G.Ambatte
2023-07-19 20:34:10 +12:00
parent 7274d788c5
commit 9e7e646296
2 changed files with 8 additions and 5 deletions

View File

@@ -16,7 +16,7 @@ const HelpNavItem = require('../../navbar/help.navitem.jsx');
const NaturalCritIcon = require('naturalcrit/svg/naturalcrit.svg.jsx'); const NaturalCritIcon = require('naturalcrit/svg/naturalcrit.svg.jsx');
const saveLocationKey = 'HOMEBREWERY-DEFAULT-SAVE-LOCATION'; let SAVEKEY = '';
const AccountPage = createClass({ const AccountPage = createClass({
displayName : 'AccountPage', displayName : 'AccountPage',
@@ -32,8 +32,9 @@ const AccountPage = createClass({
}; };
}, },
componentDidMount : function(){ componentDidMount : function(){
if(!this.state.saveLocation) { if(!this.state.saveLocation && this.props.uiItems.username) {
const saveLocation = window.localStorage.getItem(saveLocationKey) || ''; SAVEKEY = `HOMEBREWERY-DEFAULT-SAVE-LOCATION-${this.props.uiItems.username}`;
const saveLocation = window.localStorage.getItem(SAVEKEY) || '';
if(saveLocation == '') { if(saveLocation == '') {
// TO DO: Implement logic to determine the appropriate location given current state // TO DO: Implement logic to determine the appropriate location given current state
console.log(this.state.uiItems); console.log(this.state.uiItems);
@@ -46,7 +47,7 @@ const AccountPage = createClass({
makeActive : function(newSelection){ makeActive : function(newSelection){
if(this.state.saveLocation == newSelection) return; if(this.state.saveLocation == newSelection) return;
window.localStorage.setItem(saveLocationKey, newSelection); window.localStorage.setItem(SAVEKEY, newSelection);
this.setState({ this.setState({
saveLocation : newSelection saveLocation : newSelection
}); });

View File

@@ -23,7 +23,7 @@ const { DEFAULT_BREW } = require('../../../../server/brewDefaults.js');
const BREWKEY = 'homebrewery-new'; const BREWKEY = 'homebrewery-new';
const STYLEKEY = 'homebrewery-new-style'; const STYLEKEY = 'homebrewery-new-style';
const METAKEY = 'homebrewery-new-meta'; const METAKEY = 'homebrewery-new-meta';
const SAVEKEY = 'HOMEBREWERY-DEFAULT-SAVE-LOCATION'; let SAVEKEY;
const NewPage = createClass({ const NewPage = createClass({
@@ -55,6 +55,8 @@ const NewPage = createClass({
const brewStorage = localStorage.getItem(BREWKEY); const brewStorage = localStorage.getItem(BREWKEY);
const styleStorage = localStorage.getItem(STYLEKEY); const styleStorage = localStorage.getItem(STYLEKEY);
const metaStorage = JSON.parse(localStorage.getItem(METAKEY)); const metaStorage = JSON.parse(localStorage.getItem(METAKEY));
SAVEKEY = `HOMEBREWERY-DEFAULT-SAVE-LOCATION-${global.account.username}`;
const saveStorage = localStorage.getItem(SAVEKEY); const saveStorage = localStorage.getItem(SAVEKEY);
brew.text = brewStorage ?? brew.text; brew.text = brewStorage ?? brew.text;