mirror of
https://github.com/ecency/ecency-mobile.git
synced 2024-12-26 23:05:00 +03:00
Merge pull request #2491 from ecency/sa/notification-count-bug
fetch activity count when app state is changed from background to active
This commit is contained in:
commit
ad9acc2a68
@ -100,7 +100,7 @@ class ApplicationContainer extends Component {
|
||||
super(props);
|
||||
this.state = {
|
||||
isRenderRequire: true,
|
||||
isIos: Platform.OS !== 'android',
|
||||
// isIos: Platform.OS !== 'android',
|
||||
appState: AppState.currentState,
|
||||
foregroundNotificationData: null,
|
||||
};
|
||||
@ -145,7 +145,7 @@ class ApplicationContainer extends Component {
|
||||
);
|
||||
};
|
||||
|
||||
componentDidUpdate(prevProps, prevState) {
|
||||
componentDidUpdate(prevProps) {
|
||||
const { isGlobalRenderRequired, dispatch } = this.props;
|
||||
|
||||
if (isGlobalRenderRequired !== prevProps.isGlobalRenderRequired && isGlobalRenderRequired) {
|
||||
@ -218,7 +218,7 @@ class ApplicationContainer extends Component {
|
||||
};
|
||||
|
||||
_handleDeepLink = async (url = '') => {
|
||||
const { currentAccount, intl } = this.props;
|
||||
const { currentAccount } = this.props;
|
||||
|
||||
if (!url) {
|
||||
return;
|
||||
@ -308,6 +308,7 @@ class ApplicationContainer extends Component {
|
||||
|
||||
if (appState.match(/inactive|background/) && nextAppState === 'active') {
|
||||
this._refreshGlobalProps();
|
||||
this._refreshUnreadActivityCount();
|
||||
if (_isPinCodeOpen && this._pinCodeTimer) {
|
||||
clearTimeout(this._pinCodeTimer);
|
||||
}
|
||||
@ -356,7 +357,7 @@ class ApplicationContainer extends Component {
|
||||
const type = get(push, 'type', '');
|
||||
const fullPermlink =
|
||||
get(push, 'permlink1', '') + get(push, 'permlink2', '') + get(push, 'permlink3', '');
|
||||
const username = get(push, 'target', '');
|
||||
// const username = get(push, 'target', '');
|
||||
const activity_id = get(push, 'id', '');
|
||||
|
||||
switch (type) {
|
||||
@ -487,8 +488,14 @@ class ApplicationContainer extends Component {
|
||||
actions.fetchCoinQuotes();
|
||||
};
|
||||
|
||||
_refreshUnreadActivityCount = async () => {
|
||||
const { dispatch } = this.props as any;
|
||||
const unreadActivityCount = await getUnreadNotificationCount();
|
||||
dispatch(updateUnreadActivityCount(unreadActivityCount));
|
||||
};
|
||||
|
||||
_getUserDataFromRealm = async () => {
|
||||
const { dispatch, pinCode, isPinCodeOpen: _isPinCodeOpen, isConnected } = this.props;
|
||||
const { dispatch, isPinCodeOpen: _isPinCodeOpen, isConnected } = this.props;
|
||||
let realmData = [];
|
||||
|
||||
const res = await getAuthStatus();
|
||||
@ -643,8 +650,12 @@ class ApplicationContainer extends Component {
|
||||
|
||||
//update notification settings and update push token for each signed accoutn useing access tokens
|
||||
_registerDeviceForNotifications = (settings?: any) => {
|
||||
const { currentAccount, otherAccounts, notificationDetails, isNotificationsEnabled } =
|
||||
this.props;
|
||||
const {
|
||||
currentAccount,
|
||||
otherAccounts,
|
||||
notificationDetails,
|
||||
isNotificationsEnabled,
|
||||
} = this.props;
|
||||
|
||||
const isEnabled = settings ? !!settings.notification : isNotificationsEnabled;
|
||||
settings = settings || notificationDetails;
|
||||
|
Loading…
Reference in New Issue
Block a user