[react] fix: Work around an issue where the account in local storage would have set a wrong control value in localStorage
And use the correct integer for new visitors
This commit is contained in:
parent
3fd70c2447
commit
995b3b0acc
2 changed files with 7 additions and 3 deletions
|
@ -118,8 +118,12 @@ export const Editor = ({
|
|||
|
||||
const { account } = useAccount()
|
||||
|
||||
// this should be just account.control, but there was a bug where a non-logged-in user had an
|
||||
// object stored in account.control in localStorage instead of an integer
|
||||
const ux = Number.isInteger(account.control) ? account.control : 3
|
||||
|
||||
if (state.ui?.ux === undefined) {
|
||||
passDownState.ui = { ...(state.ui || {}), ux: account.control }
|
||||
passDownState.ui = { ...(state.ui || {}), ux: ux }
|
||||
}
|
||||
|
||||
return (
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
import useLocalStorageState from 'use-local-storage-state'
|
||||
import { control as defaultControlLevel } from '@freesewing/config'
|
||||
import { control as controlConfig } from '@freesewing/config'
|
||||
|
||||
/*
|
||||
* When there is no account, we use this making it easy to check for username
|
||||
* or control
|
||||
*/
|
||||
const noAccount = { username: false, control: defaultControlLevel }
|
||||
const noAccount = { username: false, control: controlConfig.dflt }
|
||||
|
||||
/*
|
||||
* FreeSewing's useAccount hook. Grants access to the (data in the) user's account
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue