mirror of
https://github.com/ecency/ecency-mobile.git
synced 2025-01-03 03:25:24 +03:00
update getActivities method to support fetching new notifications
This commit is contained in:
parent
e1bf91fe29
commit
b4153f0ff1
@ -40,15 +40,15 @@ class NotificationContainer extends Component {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_getActivities = (type = 'activities', loadMore = false) => {
|
_getActivities = (type = 'activities', loadMore = false, loadUnread = false) => {
|
||||||
const { lastNotificationId, endOfNotification, isLoading, notificationsMap } = this.state;
|
const { lastNotificationId, endOfNotification, isLoading, notificationsMap } = this.state;
|
||||||
const since = loadMore ? lastNotificationId : null;
|
const since = loadMore && !mapStateToProps ? lastNotificationId : null;
|
||||||
|
|
||||||
if (isLoading) {
|
if (isLoading) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!endOfNotification || !loadMore) {
|
if (!endOfNotification || !loadMore || loadUnread) {
|
||||||
this.setState({
|
this.setState({
|
||||||
isRefreshing: !loadMore,
|
isRefreshing: !loadMore,
|
||||||
isLoading: true,
|
isLoading: true,
|
||||||
@ -64,8 +64,12 @@ class NotificationContainer extends Component {
|
|||||||
isLoading: false,
|
isLoading: false,
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
console.log('');
|
||||||
|
const stateNotifications = notificationsMap.get(type) || [];
|
||||||
const _notifications = loadMore
|
const _notifications = loadMore
|
||||||
? unionBy(notificationsMap.get(type) || [], res, 'id')
|
? unionBy(stateNotifications, res, 'id')
|
||||||
|
: loadUnread
|
||||||
|
? unionBy(res, stateNotifications, 'id')
|
||||||
: res;
|
: res;
|
||||||
notificationsMap.set(type, _notifications);
|
notificationsMap.set(type, _notifications);
|
||||||
this.setState({
|
this.setState({
|
||||||
|
Loading…
Reference in New Issue
Block a user