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:
Feruz M 2022-10-01 12:45:18 +03:00 committed by GitHub
commit ad9acc2a68
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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;