This repository was archived by the owner on Jun 14, 2024. It is now read-only.
Description Other thing I change in the project I worked using this base-app was in the auth reducer.
I move this :
case LOAD_MNEMONIC_SUCCESS:
localStorage . setItem ( localStorage . keys . tempMnemonic , action . payload . mnemonic )
and this :
case LOAD_MNEMONIC_PERSIST: {
const mnemonic = localStorage . getItem ( localStorage . keys . tempMnemonic )
localStorage . removeItem ( localStorage . keys . tempMnemonic )
to the auth saga
so I wrap the saga like this:
export function * loadAccount ( action ) {
let mnemonic
if ( action . payload === 'from_store' ) {
mnemonic = yield select ( state => state . auth . mnemonic )
} else {
mnemonic = action . payload
}
if ( mnemonic ) {
try {
const authData = performLoadMnemonic ( mnemonic )
yield put ( loadAccountSuccess ( authData ) )
if ( action . payload !== 'from_store' ) {
yield call (
[ localStorage , 'setItem' ] ,
localStorage . keys . tempMnemonic , action . payload
)
} else {
yield call (
[ localStorage , 'setItem' ] ,
localStorage . keys . tempMnemonic , mnemonic
)
}
const mnemonicFromStorage = yield call (
[ localStorage , 'getItem' ] ,
localStorage . keys . tempMnemonic
)
yield call ( [ localStorage , 'removeItem' ] , localStorage . keys . tempMnemonic )
yield put ( loadAccountPersist ( mnemonicFromStorage ) )
} catch ( error ) {
console . error ( error )
yield put ( loadAccountFail ( ) )
}
}
}
I think it's better to have this localstorage calls inside the a saga.
I agree this saga could be improved but I think it's a start.
Reactions are currently unavailable
Other thing I change in the project I worked using this base-app was in the
auth reducer.I move this :
and this :
to the
auth sagaso I wrap the saga like this:
I think it's better to have this
localstoragecalls inside the a saga.I agree this saga could be improved but I think it's a start.