mirror of
https://github.com/ecency/ecency-mobile.git
synced 2024-12-30 00:52:42 +03:00
created disable notificaiton when user logout
This commit is contained in:
parent
8ee7d4b702
commit
6d504a5032
@ -7,6 +7,7 @@ import { NavigationActions } from 'react-navigation';
|
|||||||
import { bindActionCreators } from 'redux';
|
import { bindActionCreators } from 'redux';
|
||||||
import Push from 'appcenter-push';
|
import Push from 'appcenter-push';
|
||||||
import get from 'lodash/get';
|
import get from 'lodash/get';
|
||||||
|
import AppCenter from 'appcenter';
|
||||||
|
|
||||||
// Languages
|
// Languages
|
||||||
import en from 'react-intl/locale-data/en';
|
import en from 'react-intl/locale-data/en';
|
||||||
@ -40,6 +41,7 @@ import {
|
|||||||
} from '../../../realm/realm';
|
} from '../../../realm/realm';
|
||||||
import { getUser } from '../../../providers/steem/dsteem';
|
import { getUser } from '../../../providers/steem/dsteem';
|
||||||
import { switchAccount } from '../../../providers/steem/auth';
|
import { switchAccount } from '../../../providers/steem/auth';
|
||||||
|
import { setPushToken } from '../../../providers/esteem/esteem';
|
||||||
|
|
||||||
// Actions
|
// Actions
|
||||||
import {
|
import {
|
||||||
@ -333,11 +335,17 @@ class ApplicationContainer extends Component {
|
|||||||
};
|
};
|
||||||
|
|
||||||
_logout = async () => {
|
_logout = async () => {
|
||||||
const { otherAccounts, currentAccount, dispatch } = this.props;
|
const {
|
||||||
|
otherAccounts,
|
||||||
|
currentAccount: { name, local },
|
||||||
|
dispatch,
|
||||||
|
} = this.props;
|
||||||
|
|
||||||
await removeUserData(currentAccount.name)
|
await removeUserData(name)
|
||||||
.then(async () => {
|
.then(async () => {
|
||||||
const _otherAccounts = otherAccounts.filter(user => user.username !== currentAccount.name);
|
const _otherAccounts = otherAccounts.filter(user => user.username !== name);
|
||||||
|
|
||||||
|
this._enableNotification(name, false);
|
||||||
|
|
||||||
if (_otherAccounts.length > 0) {
|
if (_otherAccounts.length > 0) {
|
||||||
const targetAccountUsername = _otherAccounts[0].username;
|
const targetAccountUsername = _otherAccounts[0].username;
|
||||||
@ -349,12 +357,12 @@ class ApplicationContainer extends Component {
|
|||||||
removePinCode();
|
removePinCode();
|
||||||
setAuthStatus({ isLoggedIn: false });
|
setAuthStatus({ isLoggedIn: false });
|
||||||
setExistUser(false);
|
setExistUser(false);
|
||||||
if (currentAccount.local === AUTH_TYPE.STEEM_CONNECT) {
|
if (local === AUTH_TYPE.STEEM_CONNECT) {
|
||||||
removeSCAccount(currentAccount.name);
|
removeSCAccount(name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dispatch(removeOtherAccount(currentAccount.name));
|
dispatch(removeOtherAccount(name));
|
||||||
dispatch(logoutDone());
|
dispatch(logoutDone());
|
||||||
})
|
})
|
||||||
.catch(err => {
|
.catch(err => {
|
||||||
@ -367,6 +375,18 @@ class ApplicationContainer extends Component {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
_enableNotification = async (username, isEnable) => {
|
||||||
|
const token = await AppCenter.getInstallId();
|
||||||
|
|
||||||
|
setPushToken({
|
||||||
|
username,
|
||||||
|
token,
|
||||||
|
system: Platform.OS,
|
||||||
|
allows_notify: Number(isEnable),
|
||||||
|
notify_types: [1, 2, 3, 4, 5, 6],
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
_switchAccount = async targetAccountUsername => {
|
_switchAccount = async targetAccountUsername => {
|
||||||
const { dispatch } = this.props;
|
const { dispatch } = this.props;
|
||||||
|
|
||||||
|
@ -154,15 +154,15 @@ class SettingsScreen extends PureComponent {
|
|||||||
<CollapsibleCard
|
<CollapsibleCard
|
||||||
titleComponent={
|
titleComponent={
|
||||||
<SettingsItem
|
<SettingsItem
|
||||||
title={intl.formatMessage({
|
title={intl.formatMessage({
|
||||||
id: 'settings.push_notification',
|
id: 'settings.push_notification',
|
||||||
})}
|
})}
|
||||||
titleStyle={styles.cardTitle}
|
titleStyle={styles.cardTitle}
|
||||||
type="toggle"
|
type="toggle"
|
||||||
actionType="notification"
|
actionType="notification"
|
||||||
isOn={isNotificationSettingsOpen}
|
isOn={isNotificationSettingsOpen}
|
||||||
handleOnChange={handleOnChange}
|
handleOnChange={handleOnChange}
|
||||||
/>
|
/>
|
||||||
}
|
}
|
||||||
noBorder
|
noBorder
|
||||||
fitContent
|
fitContent
|
||||||
|
Loading…
Reference in New Issue
Block a user