0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2025-12-29 04:42:41 +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
});

View File

@@ -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;