Eslint errors fixed for application container

This commit is contained in:
Mustafa Buyukcelebi 2018-12-25 15:15:32 +03:00
parent 20d5c95a44
commit f31a0f2607

View File

@ -93,23 +93,21 @@ class ApplicationContainer extends Component {
_getUserData = async () => { _getUserData = async () => {
const { dispatch } = this.props; const { dispatch } = this.props;
let realmData; let realmData;
let authStatus;
let currentUsername; let currentUsername;
await getAuthStatus().then((res) => { await getAuthStatus().then((res) => {
authStatus = res; ({ currentUsername } = res);
currentUsername = res.currentUsername; if (res) {
getUserData().then((userData) => { getUserData().then((userData) => {
if (userData.length > 0) { if (userData.length > 0) {
realmData = userData; realmData = userData;
userData.forEach((accountData) => { userData.forEach((accountData) => {
dispatch( dispatch(addOtherAccount({ username: accountData.username }));
addOtherAccount({ username: accountData.username }), });
); }
}); });
} }
});
}); });
if (realmData) { if (realmData) {
@ -118,10 +116,11 @@ class ApplicationContainer extends Component {
dispatch(login(true)); dispatch(login(true));
const realmObject = realmData.filter(data => data.username === currentUsername); const realmObject = realmData.filter(data => data.username === currentUsername);
accountData.local = realmObject[0]; [accountData.local] = realmObject;
dispatch(updateCurrentAccount(accountData)); dispatch(updateCurrentAccount(accountData));
// If in dev mode pin code does not show // If in dev mode pin code does not show
// eslint-disable-next-line
if (__DEV__ === false) { if (__DEV__ === false) {
dispatch(openPinCodeModal()); dispatch(openPinCodeModal());
} }
@ -142,12 +141,12 @@ class ApplicationContainer extends Component {
getSettings().then((response) => { getSettings().then((response) => {
if (response) { if (response) {
response.isDarkTheme && dispatch(isDarkTheme(response.isDarkTheme)); if (response.isDarkTheme) dispatch(isDarkTheme(response.isDarkTheme));
response.language && dispatch(setLanguage(response.language)); if (response.language) dispatch(setLanguage(response.language));
response.currency && dispatch(setCurrency(response.currency)); if (response.currency) dispatch(setCurrency(response.currency));
response.notification && dispatch(isNotificationOpen(response.notification)); if (response.notification) dispatch(isNotificationOpen(response.notification));
response.server && dispatch(setApi(response.server)); if (response.server) dispatch(setApi(response.server));
response.upvotePercent && dispatch(setUpvotePercent(Number(response.upvotePercent))); if (response.upvotePercent) dispatch(setUpvotePercent(Number(response.upvotePercent)));
this.setState({ isReady: true }); this.setState({ isReady: true });
} }
@ -158,7 +157,7 @@ class ApplicationContainer extends Component {
const { dispatch, unreadActivityCount } = this.props; const { dispatch, unreadActivityCount } = this.props;
const ws = new WebSocket(`${Config.ACTIVITY_WEBSOCKET_URL}?user=${username}`); const ws = new WebSocket(`${Config.ACTIVITY_WEBSOCKET_URL}?user=${username}`);
ws.onmessage = (e) => { ws.onmessage = () => {
// a message was received // a message was received
dispatch(updateUnreadActivityCount(unreadActivityCount + 1)); dispatch(updateUnreadActivityCount(unreadActivityCount + 1));
}; };
@ -188,9 +187,7 @@ class ApplicationContainer extends Component {
}; };
_logout = () => { _logout = () => {
const { const { otherAccounts, currentAccountUsername, dispatch } = this.props;
otherAccounts, currentAccountUsername, dispatch,
} = this.props;
removeUserData(currentAccountUsername) removeUserData(currentAccountUsername)
.then(() => { .then(() => {
@ -210,8 +207,7 @@ class ApplicationContainer extends Component {
dispatch(removeOtherAccount(currentAccountUsername)); dispatch(removeOtherAccount(currentAccountUsername));
dispatch(logoutDone()); dispatch(logoutDone());
}) })
.catch((err) => { .catch(() => {
alert('err');
}); });
}; };
@ -222,11 +218,11 @@ class ApplicationContainer extends Component {
const realmData = getUserDataWithUsername(targetAccountUsername); const realmData = getUserDataWithUsername(targetAccountUsername);
const _currentAccount = accountData; const _currentAccount = accountData;
_currentAccount.username = accountData.name; _currentAccount.username = accountData.name;
_currentAccount.local = realmData[0]; [_currentAccount.local] = realmData;
dispatch(updateCurrentAccount(_currentAccount)); dispatch(updateCurrentAccount(_currentAccount));
}); });
} };
render() { render() {
const { selectedLanguage } = this.props; const { selectedLanguage } = this.props;