mirror of
https://github.com/ecency/ecency-mobile.git
synced 2024-12-18 19:01:38 +03:00
added migration script to bottom sheet switcher and fixed check logic
This commit is contained in:
parent
b6b80e7a7b
commit
97109ddc24
@ -7,11 +7,14 @@ import { updateCurrentAccount } from '../../../redux/actions/accountAction';
|
|||||||
import { isRenderRequired } from '../../../redux/actions/applicationActions';
|
import { isRenderRequired } from '../../../redux/actions/applicationActions';
|
||||||
|
|
||||||
import { getUserDataWithUsername } from '../../../realm/realm';
|
import { getUserDataWithUsername } from '../../../realm/realm';
|
||||||
import { switchAccount } from '../../../providers/hive/auth';
|
import { migrateToMasterKeyWithAccessToken, switchAccount } from '../../../providers/hive/auth';
|
||||||
|
|
||||||
import AccountsBottomSheet from '../view/accountsBottomSheetView';
|
import AccountsBottomSheet from '../view/accountsBottomSheetView';
|
||||||
import { toggleAccountsBottomSheet } from '../../../redux/actions/uiAction';
|
import { toggleAccountsBottomSheet } from '../../../redux/actions/uiAction';
|
||||||
|
|
||||||
|
//Constants
|
||||||
|
import AUTH_TYPE from '../../../constants/authType';
|
||||||
|
|
||||||
const AccountsBottomSheetContainer = ({ navigation }) => {
|
const AccountsBottomSheetContainer = ({ navigation }) => {
|
||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch();
|
||||||
const accountsBottomSheetViewRef = useRef();
|
const accountsBottomSheetViewRef = useRef();
|
||||||
@ -21,6 +24,8 @@ const AccountsBottomSheetContainer = ({ navigation }) => {
|
|||||||
);
|
);
|
||||||
const currentAccount = useSelector((state) => state.account.currentAccount);
|
const currentAccount = useSelector((state) => state.account.currentAccount);
|
||||||
const accounts = useSelector((state) => state.account.otherAccounts);
|
const accounts = useSelector((state) => state.account.otherAccounts);
|
||||||
|
const pinHash = useSelector((state)=>state.application.pin);
|
||||||
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (isVisibleAccountsBottomSheet) {
|
if (isVisibleAccountsBottomSheet) {
|
||||||
@ -61,12 +66,17 @@ const AccountsBottomSheetContainer = ({ navigation }) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//fetch upto data account data nd update current account;
|
//fetch upto data account data nd update current account;
|
||||||
const _currentAccount = await switchAccount(accountData.username);
|
let _currentAccount = await switchAccount(accountData.username);
|
||||||
const realmData = await getUserDataWithUsername(accountData.username);
|
const realmData = await getUserDataWithUsername(accountData.username);
|
||||||
|
|
||||||
_currentAccount.username = _currentAccount.name;
|
_currentAccount.username = _currentAccount.name;
|
||||||
_currentAccount.local = realmData[0];
|
_currentAccount.local = realmData[0];
|
||||||
|
|
||||||
|
//migreate account to use access token for master key auth type
|
||||||
|
if (realmData[0].authType === AUTH_TYPE.MASTER_KEY && realmData[0].accessToken === "") {
|
||||||
|
_currentAccount = await migrateToMasterKeyWithAccessToken(_currentAccount, pinHash);
|
||||||
|
}
|
||||||
|
|
||||||
dispatch(updateCurrentAccount(_currentAccount));
|
dispatch(updateCurrentAccount(_currentAccount));
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -812,7 +812,7 @@ class ApplicationContainer extends Component {
|
|||||||
[_currentAccount.local] = realmData;
|
[_currentAccount.local] = realmData;
|
||||||
|
|
||||||
//migreate account to use access token for master key auth type
|
//migreate account to use access token for master key auth type
|
||||||
if (realmData[0].authType === AUTH_TYPE.MASTER_KEY && realmData[0].accessToken) {
|
if (realmData[0].authType === AUTH_TYPE.MASTER_KEY && realmData[0].accessToken === "") {
|
||||||
_currentAccount = await migrateToMasterKeyWithAccessToken(_currentAccount, pinCode);
|
_currentAccount = await migrateToMasterKeyWithAccessToken(_currentAccount, pinCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user