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);
|
super(props);
|
||||||
this.state = {
|
this.state = {
|
||||||
isRenderRequire: true,
|
isRenderRequire: true,
|
||||||
isIos: Platform.OS !== 'android',
|
// isIos: Platform.OS !== 'android',
|
||||||
appState: AppState.currentState,
|
appState: AppState.currentState,
|
||||||
foregroundNotificationData: null,
|
foregroundNotificationData: null,
|
||||||
};
|
};
|
||||||
@ -145,7 +145,7 @@ class ApplicationContainer extends Component {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
componentDidUpdate(prevProps, prevState) {
|
componentDidUpdate(prevProps) {
|
||||||
const { isGlobalRenderRequired, dispatch } = this.props;
|
const { isGlobalRenderRequired, dispatch } = this.props;
|
||||||
|
|
||||||
if (isGlobalRenderRequired !== prevProps.isGlobalRenderRequired && isGlobalRenderRequired) {
|
if (isGlobalRenderRequired !== prevProps.isGlobalRenderRequired && isGlobalRenderRequired) {
|
||||||
@ -218,7 +218,7 @@ class ApplicationContainer extends Component {
|
|||||||
};
|
};
|
||||||
|
|
||||||
_handleDeepLink = async (url = '') => {
|
_handleDeepLink = async (url = '') => {
|
||||||
const { currentAccount, intl } = this.props;
|
const { currentAccount } = this.props;
|
||||||
|
|
||||||
if (!url) {
|
if (!url) {
|
||||||
return;
|
return;
|
||||||
@ -308,6 +308,7 @@ class ApplicationContainer extends Component {
|
|||||||
|
|
||||||
if (appState.match(/inactive|background/) && nextAppState === 'active') {
|
if (appState.match(/inactive|background/) && nextAppState === 'active') {
|
||||||
this._refreshGlobalProps();
|
this._refreshGlobalProps();
|
||||||
|
this._refreshUnreadActivityCount();
|
||||||
if (_isPinCodeOpen && this._pinCodeTimer) {
|
if (_isPinCodeOpen && this._pinCodeTimer) {
|
||||||
clearTimeout(this._pinCodeTimer);
|
clearTimeout(this._pinCodeTimer);
|
||||||
}
|
}
|
||||||
@ -356,7 +357,7 @@ class ApplicationContainer extends Component {
|
|||||||
const type = get(push, 'type', '');
|
const type = get(push, 'type', '');
|
||||||
const fullPermlink =
|
const fullPermlink =
|
||||||
get(push, 'permlink1', '') + get(push, 'permlink2', '') + get(push, 'permlink3', '');
|
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', '');
|
const activity_id = get(push, 'id', '');
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
@ -487,8 +488,14 @@ class ApplicationContainer extends Component {
|
|||||||
actions.fetchCoinQuotes();
|
actions.fetchCoinQuotes();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
_refreshUnreadActivityCount = async () => {
|
||||||
|
const { dispatch } = this.props as any;
|
||||||
|
const unreadActivityCount = await getUnreadNotificationCount();
|
||||||
|
dispatch(updateUnreadActivityCount(unreadActivityCount));
|
||||||
|
};
|
||||||
|
|
||||||
_getUserDataFromRealm = async () => {
|
_getUserDataFromRealm = async () => {
|
||||||
const { dispatch, pinCode, isPinCodeOpen: _isPinCodeOpen, isConnected } = this.props;
|
const { dispatch, isPinCodeOpen: _isPinCodeOpen, isConnected } = this.props;
|
||||||
let realmData = [];
|
let realmData = [];
|
||||||
|
|
||||||
const res = await getAuthStatus();
|
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
|
//update notification settings and update push token for each signed accoutn useing access tokens
|
||||||
_registerDeviceForNotifications = (settings?: any) => {
|
_registerDeviceForNotifications = (settings?: any) => {
|
||||||
const { currentAccount, otherAccounts, notificationDetails, isNotificationsEnabled } =
|
const {
|
||||||
this.props;
|
currentAccount,
|
||||||
|
otherAccounts,
|
||||||
|
notificationDetails,
|
||||||
|
isNotificationsEnabled,
|
||||||
|
} = this.props;
|
||||||
|
|
||||||
const isEnabled = settings ? !!settings.notification : isNotificationsEnabled;
|
const isEnabled = settings ? !!settings.notification : isNotificationsEnabled;
|
||||||
settings = settings || notificationDetails;
|
settings = settings || notificationDetails;
|
||||||
|
Loading…
Reference in New Issue
Block a user