Merge branch 'master' of https://github.com/esteemapp/esteem-mobile into bugfix/comment-vote

This commit is contained in:
u-e 2019-06-17 19:49:13 +03:00
commit f7bde29606
3 changed files with 38 additions and 27 deletions

View File

@ -127,6 +127,7 @@ export default class TagAreaView extends Component {
}
autoCapitalize="none"
onFocus={() => this.setState({ activeChip: i })}
autoCorrect={false}
/>
),
)}

View File

@ -42,13 +42,13 @@ class NotificationView extends PureComponent {
// Component Functions
_handleOnDropdownSelect = index => {
_handleOnDropdownSelect = async index => {
const { getActivities, changeSelectedFilter } = this.props;
const { filters } = this.state;
this.setState({ selectedFilter: filters[index].key });
changeSelectedFilter(filters[index].key);
getActivities(filters[index].key, false);
await changeSelectedFilter(filters[index].key);
getActivities(null, filters[index].key, false);
};
_renderList = data => {
@ -176,7 +176,7 @@ class NotificationView extends PureComponent {
refreshing={isNotificationRefreshing}
onRefresh={() => getActivities()}
keyExtractor={item => item.title}
onEndReached={() => getActivities(selectedFilter, true)}
onEndReached={() => getActivities(null, selectedFilter, true)}
ListFooterComponent={this._renderFooterLoading}
refreshControl={
<RefreshControl

View File

@ -20,6 +20,7 @@ class NotificationContainer extends Component {
lastNotificationId: null,
isNotificationRefreshing: false,
selectedFilter: 'activities',
endOfNotification: false,
};
}
@ -39,28 +40,37 @@ class NotificationContainer extends Component {
(nextProps.activeBottomTab === ROUTES.TABBAR.NOTIFICATION && nextProps.username) ||
(nextProps.username !== username && nextProps.username)
) {
this._getAvtivities(nextProps.username, selectedFilter);
this.setState({ endOfNotification: false }, () =>
this._getAvtivities(nextProps.username, selectedFilter),
);
}
}
_getAvtivities = (user, type = null, loadMore = false) => {
const { lastNotificationId, notifications } = this.state;
const { lastNotificationId, notifications, endOfNotification } = this.state;
const since = loadMore ? lastNotificationId : null;
const { username } = this.props;
if (!endOfNotification) {
this.setState({ isNotificationRefreshing: true });
getActivities({ user: user || username, type, since })
.then(res => {
const lastId = [...res].pop().id;
const lastId = res.length > 0 ? [...res].pop().id : null;
if (lastId === lastNotificationId || res.length === 0) {
this.setState({
endOfNotification: true,
isNotificationRefreshing: false,
});
} else {
this.setState({
notifications: loadMore ? [...notifications, ...res] : res,
lastNotificationId: lastId,
isNotificationRefreshing: false,
});
}
})
.catch(() => this.setState({ isNotificationRefreshing: false }));
}
};
_navigateToNotificationRoute = data => {
@ -122,8 +132,8 @@ class NotificationContainer extends Component {
navigation.navigate(ROUTES.SCREENS.LOGIN);
};
_changeSelectedFilter = value => {
this.setState({ selectedFilter: value });
_changeSelectedFilter = async value => {
await this.setState({ selectedFilter: value, endOfNotification: false });
};
render() {