mirror of
https://github.com/ecency/ecency-mobile.git
synced 2025-01-03 11:34:30 +03:00
Merge pull request #911 from esteemapp/bugfix/notifications
Fixed notification screens bugs
This commit is contained in:
commit
8c59f5f330
@ -42,13 +42,13 @@ class NotificationView extends PureComponent {
|
|||||||
|
|
||||||
// Component Functions
|
// Component Functions
|
||||||
|
|
||||||
_handleOnDropdownSelect = index => {
|
_handleOnDropdownSelect = async index => {
|
||||||
const { getActivities, changeSelectedFilter } = this.props;
|
const { getActivities, changeSelectedFilter } = this.props;
|
||||||
const { filters } = this.state;
|
const { filters } = this.state;
|
||||||
|
|
||||||
this.setState({ selectedFilter: filters[index].key });
|
this.setState({ selectedFilter: filters[index].key });
|
||||||
changeSelectedFilter(filters[index].key);
|
await changeSelectedFilter(filters[index].key);
|
||||||
getActivities(filters[index].key, false);
|
getActivities(null, filters[index].key, false);
|
||||||
};
|
};
|
||||||
|
|
||||||
_renderList = data => {
|
_renderList = data => {
|
||||||
@ -176,16 +176,16 @@ class NotificationView extends PureComponent {
|
|||||||
refreshing={isNotificationRefreshing}
|
refreshing={isNotificationRefreshing}
|
||||||
onRefresh={() => getActivities()}
|
onRefresh={() => getActivities()}
|
||||||
keyExtractor={item => item.title}
|
keyExtractor={item => item.title}
|
||||||
onEndReached={() => getActivities(selectedFilter, true)}
|
onEndReached={() => getActivities(null, selectedFilter, true)}
|
||||||
ListFooterComponent={this._renderFooterLoading}
|
ListFooterComponent={this._renderFooterLoading}
|
||||||
refreshControl={
|
refreshControl={
|
||||||
<RefreshControl
|
<RefreshControl
|
||||||
refreshing={isNotificationRefreshing}
|
refreshing={isNotificationRefreshing}
|
||||||
progressBackgroundColor="#357CE6"
|
progressBackgroundColor="#357CE6"
|
||||||
tintColor={!isDarkTheme ? '#357ce6' : '#96c0ff'}
|
tintColor={!isDarkTheme ? '#357ce6' : '#96c0ff'}
|
||||||
titleColor="#fff"
|
titleColor="#fff"
|
||||||
colors={['#fff']}
|
colors={['#fff']}
|
||||||
/>
|
/>
|
||||||
}
|
}
|
||||||
renderItem={({ item, index }) => (
|
renderItem={({ item, index }) => (
|
||||||
<Fragment>
|
<Fragment>
|
||||||
|
@ -20,6 +20,7 @@ class NotificationContainer extends Component {
|
|||||||
lastNotificationId: null,
|
lastNotificationId: null,
|
||||||
isNotificationRefreshing: false,
|
isNotificationRefreshing: false,
|
||||||
selectedFilter: 'activities',
|
selectedFilter: 'activities',
|
||||||
|
endOfNotification: false,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -39,28 +40,37 @@ class NotificationContainer extends Component {
|
|||||||
(nextProps.activeBottomTab === ROUTES.TABBAR.NOTIFICATION && nextProps.username) ||
|
(nextProps.activeBottomTab === ROUTES.TABBAR.NOTIFICATION && nextProps.username) ||
|
||||||
(nextProps.username !== username && 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) => {
|
_getAvtivities = (user, type = null, loadMore = false) => {
|
||||||
const { lastNotificationId, notifications } = this.state;
|
const { lastNotificationId, notifications, endOfNotification } = this.state;
|
||||||
const since = loadMore ? lastNotificationId : null;
|
const since = loadMore ? lastNotificationId : null;
|
||||||
const { username } = this.props;
|
const { username } = this.props;
|
||||||
|
|
||||||
this.setState({ isNotificationRefreshing: true });
|
if (!endOfNotification) {
|
||||||
|
this.setState({ isNotificationRefreshing: true });
|
||||||
getActivities({ user: user || username, type, since })
|
getActivities({ user: user || username, type, since })
|
||||||
.then(res => {
|
.then(res => {
|
||||||
const lastId = [...res].pop().id;
|
const lastId = res.length > 0 ? [...res].pop().id : null;
|
||||||
|
if (lastId === lastNotificationId || res.length === 0) {
|
||||||
this.setState({
|
this.setState({
|
||||||
notifications: loadMore ? [...notifications, ...res] : res,
|
endOfNotification: true,
|
||||||
lastNotificationId: lastId,
|
isNotificationRefreshing: false,
|
||||||
isNotificationRefreshing: false,
|
});
|
||||||
});
|
} else {
|
||||||
})
|
this.setState({
|
||||||
.catch(() => this.setState({ isNotificationRefreshing: false }));
|
notifications: loadMore ? [...notifications, ...res] : res,
|
||||||
|
lastNotificationId: lastId,
|
||||||
|
isNotificationRefreshing: false,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch(() => this.setState({ isNotificationRefreshing: false }));
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
_navigateToNotificationRoute = data => {
|
_navigateToNotificationRoute = data => {
|
||||||
@ -122,8 +132,8 @@ class NotificationContainer extends Component {
|
|||||||
navigation.navigate(ROUTES.SCREENS.LOGIN);
|
navigation.navigate(ROUTES.SCREENS.LOGIN);
|
||||||
};
|
};
|
||||||
|
|
||||||
_changeSelectedFilter = value => {
|
_changeSelectedFilter = async value => {
|
||||||
this.setState({ selectedFilter: value });
|
await this.setState({ selectedFilter: value, endOfNotification: false });
|
||||||
};
|
};
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
Loading…
Reference in New Issue
Block a user