mirror of
https://github.com/ecency/ecency-mobile.git
synced 2025-01-02 19:06:39 +03:00
Merge pull request #204 from esteemapp/bugfix/notification
Added mark all notification as read feature fixed #163
This commit is contained in:
commit
d3abc6efca
@ -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 && (
|
||||
|
@ -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"
|
||||
}
|
||||
}
|
||||
|
@ -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"
|
||||
}
|
||||
}
|
||||
|
@ -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));
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user