This commit is contained in:
Mustafa Buyukcelebi 2019-03-28 17:15:42 +03:00
parent 264f7a8945
commit 8ea51e5aa2
4 changed files with 17 additions and 2 deletions

View File

@ -35,6 +35,7 @@ class NotificationView extends PureComponent {
{ key: 'mentions', value: 'MENTIONS' },
{ key: 'follows', value: 'FOLLOWS' },
{ key: 'reblogs', value: 'REBLOGS' },
{ key: 'transfers', value: 'TRANSFERS' },
],
selectedFilter: null,
};
@ -45,10 +46,11 @@ class NotificationView extends PureComponent {
// Component Functions
_handleOnDropdownSelect = (index) => {
const { getActivities } = this.props;
const { getActivities, changeSelectedFilter } = this.props;
const { filters } = this.state;
this.setState({ selectedFilter: filters[index].key });
changeSelectedFilter(filters[index].key);
getActivities(filters[index].key, false);
};

View File

@ -144,6 +144,9 @@ export const getActivities = data => new Promise((resolve, reject) => {
case 'reblogs':
url = `/reblogs/${data.user}`;
break;
case 'transfers':
url = `/transfers/${data.user}`;
break;
default:
url = `/activities/${data.user}`;
break;

View File

@ -19,6 +19,7 @@ class NotificationContainer extends Component {
lastNotificationId: null,
notificationLoading: false,
readAllNotificationLoading: false,
selectedFilter: 'activities',
};
}
@ -31,8 +32,10 @@ class NotificationContainer extends Component {
}
componentWillReceiveProps(nextProps) {
const { selectedFilter } = this.state;
if (nextProps.activeBottomTab === ROUTES.TABBAR.NOTIFICATION && nextProps.username) {
this._getAvtivities();
this._getAvtivities(selectedFilter);
}
}
@ -110,6 +113,10 @@ class NotificationContainer extends Component {
navigation.navigate(ROUTES.SCREENS.LOGIN);
};
_changeSelectedFilter = (value) => {
this.setState({ selectedFilter: value });
};
render() {
const { isLoggedIn } = this.props;
const {
@ -130,6 +137,7 @@ class NotificationContainer extends Component {
notificationLoading={notificationLoading}
readAllNotificationLoading={readAllNotificationLoading}
isLoggedIn={isLoggedIn}
changeSelectedFilter={this._changeSelectedFilter}
/>
);
}

View File

@ -31,6 +31,7 @@ class NotificationScreen extends PureComponent {
isLoggedIn,
notificationLoading,
readAllNotificationLoading,
changeSelectedFilter,
} = this.props;
return (
@ -56,6 +57,7 @@ class NotificationScreen extends PureComponent {
readAllNotification={readAllNotification}
readAllNotificationLoading={readAllNotificationLoading}
loading={notificationLoading}
changeSelectedFilter={changeSelectedFilter}
/>
) : (
<NoPost