Merge pull request #204 from esteemapp/bugfix/notification

Added mark all notification as read feature fixed #163
This commit is contained in:
Feruz M 2018-12-09 19:53:24 +02:00 committed by GitHub
commit d3abc6efca
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 40 additions and 3 deletions

View File

@ -48,7 +48,9 @@ class NotificationView extends Component {
};
render() {
const { notifications, intl, navigateToNotificationRoute } = this.props;
const {
notifications, intl, navigateToNotificationRoute, readAllNotification,
} = this.props;
const { filters } = this.state;
const today = [];
const yesterday = [];
@ -78,6 +80,7 @@ class NotificationView extends Component {
defaultText="ALL ACTIVITIES"
onDropdownSelect={this._handleOnDropdownSelect}
rightIconName="ios-checkmark"
onRightIconPress={readAllNotification}
/>
<ScrollView style={styles.scrollView}>
{today.length > 0 && (

View File

@ -112,5 +112,9 @@
"set_new": "Set new pin",
"write_again": "Write again",
"forgot_text": "Oh, I forgot it..."
},
"alert": {
"success": "Success!",
"allRead": "Marked all notification as read"
}
}

View File

@ -112,5 +112,9 @@
"set_new": "Yeni pin kodu",
"write_again": "Tekrar giriniz",
"forgot_text": "Of! unuttum..."
},
"alert": {
"success": "Başarılı!",
"allRead": "Tüm bildirimler okundu"
}
}

View File

@ -1,5 +1,7 @@
import React, { Component } from 'react';
import { Alert } from 'react-native';
import { connect } from 'react-redux';
import { injectIntl } from 'react-intl';
// Actions and Services
import { getActivities, markActivityAsRead } from '../../../providers/esteem/esteem';
@ -62,6 +64,24 @@ class NotificationContainer extends Component {
}
};
_readAllNotification = () => {
const { username, dispatch, intl } = this.props;
const { notifications } = this.state;
markActivityAsRead(username).then((result) => {
dispatch(updateUnreadActivityCount(result.unread));
const updatedNotifications = notifications.map(item => ({ ...item, read: 1 }));
this.setState({ notifications: updatedNotifications });
Alert.alert(
intl.formatMessage({
id: 'alert.success',
}),
intl.formatMessage({
id: 'alert.allRead',
}),
);
});
};
render() {
const { notifications } = this.state;
@ -70,6 +90,7 @@ class NotificationContainer extends Component {
getActivities={this._getAvtivities}
notifications={notifications}
navigateToNotificationRoute={this._navigateToNotificationRoute}
readAllNotification={this._readAllNotification}
{...this.props}
/>
);
@ -81,4 +102,4 @@ const mapStateToProps = state => ({
activeBottomTab: state.ui.activeBottomTab,
});
export default connect(mapStateToProps)(NotificationContainer);
export default connect(mapStateToProps)(injectIntl(NotificationContainer));

View File

@ -23,7 +23,11 @@ class NotificationScreen extends PureComponent {
render() {
const {
notifications, getActivities, intl, navigateToNotificationRoute,
notifications,
getActivities,
intl,
navigateToNotificationRoute,
readAllNotification,
} = this.props;
return (
<View style={styles.container}>
@ -44,6 +48,7 @@ class NotificationScreen extends PureComponent {
getActivities={getActivities}
notifications={notifications}
navigateToNotificationRoute={navigateToNotificationRoute}
readAllNotification={readAllNotification}
/>
</View>
<View