0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2026-01-20 22:32:45 +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 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
});