Merge pull request #1469 from esteemapp/bugfix/account-switch

Bugfix/account switch
This commit is contained in:
Feruz M 2020-01-07 14:52:28 +02:00 committed by GitHub
commit 80b342dd4e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 26 additions and 1 deletions

View File

@ -6,7 +6,7 @@ import { getUserDataWithUsername } from '../../../realm/realm';
import { switchAccount } from '../../../providers/steem/auth';
import { updateCurrentAccount } from '../../../redux/actions/accountAction';
import { logout } from '../../../redux/actions/applicationActions';
import { logout, isRenderRequired } from '../../../redux/actions/applicationActions';
// Constanst
import { default as ROUTES } from '../../../constants/routeNames';
@ -73,6 +73,7 @@ class SideMenuContainer extends Component {
_currentAccount.local = realmData[0];
dispatch(updateCurrentAccount(_currentAccount));
dispatch(isRenderRequired(true));
navigation.closeDrawer();
});
}

View File

@ -26,6 +26,7 @@ import {
SET_UPVOTE_PERCENT,
SET_PIN_CODE,
IS_PIN_CODE_OPEN,
IS_RENDER_REQUIRED,
} from '../constants/constants';
export const login = payload => ({
@ -171,3 +172,8 @@ export const setPinCode = data => ({
type: SET_PIN_CODE,
payload: data,
});
export const isRenderRequired = payload => ({
payload,
type: IS_RENDER_REQUIRED,
});

View File

@ -13,6 +13,7 @@ export const IS_LOGGED_IN = 'IS_LOGGED_IN';
export const IS_LOGIN_DONE = 'IS_LOGIN_DONE';
export const IS_NOTIFICATION_OPEN = 'IS_NOTIFICATION_OPEN';
export const IS_DEFAULT_FOOTER = 'IS_DEFAULT_FOOTER';
export const IS_RENDER_REQUIRED = 'IS_RENDER_REQUIRED';
export const LOGIN = 'LOGIN';
export const LOGOUT = 'LOGOUT';
export const LOGOUT_DONE = 'LOGOUT_DONE';

View File

@ -24,6 +24,7 @@ import {
SET_UPVOTE_PERCENT,
SET_PIN_CODE,
IS_PIN_CODE_OPEN,
IS_RENDER_REQUIRED,
} from '../constants/constants';
const initialState = {
@ -57,6 +58,7 @@ const initialState = {
nsfw: 'Always show',
pin: null,
isPinCodeOpen: true,
isRenderRequired: false,
};
export default function(state = initialState, action) {
@ -198,6 +200,10 @@ export default function(state = initialState, action) {
...state,
pin: action.payload,
};
case IS_RENDER_REQUIRED:
return Object.assign({}, state, {
isRenderRequired: action.payload,
});
default:
return state;
}

View File

@ -66,6 +66,7 @@ import {
isDefaultFooter,
isPinCodeOpen,
setPinCode as savePinCode,
isRenderRequired,
} from '../../../redux/actions/applicationActions';
import { updateActiveBottomTab } from '../../../redux/actions/uiAction';
@ -122,6 +123,15 @@ class ApplicationContainer extends Component {
if (!isIos) BackHandler.addEventListener('hardwareBackPress', this._onBackPress);
};
componentDidUpdate(prevProps, prevState) {
const { isGlobalRenderRequired, dispatch } = this.props;
if (isGlobalRenderRequired !== prevProps.isGlobalRenderRequired && isGlobalRenderRequired) {
this.setState({ isRenderRequire: false }, () => this.setState({ isRenderRequire: true }));
dispatch(isRenderRequired(false));
}
}
componentWillUnmount() {
const { isIos } = this.state;
const { isPinCodeOpen: _isPinCodeOpen } = this.props;
@ -652,6 +662,7 @@ export default connect(
isPinCodeRequire: state.application.isPinCodeRequire,
isActiveApp: state.application.isActive,
api: state.application.api,
isGlobalRenderRequired: state.application.isRenderRequired,
// Account
unreadActivityCount: state.account.currentAccount.unread_activity_count,