Fix minor bugs
parent
312c936d51
commit
787d5d7289
|
@ -105,15 +105,15 @@ export function submitMarkers() {
|
||||||
};
|
};
|
||||||
|
|
||||||
export const fetchMarkers = () => (dispatch, getState) => {
|
export const fetchMarkers = () => (dispatch, getState) => {
|
||||||
const params = { timeline: ['notifications'] };
|
const params = { timeline: ['notifications'] };
|
||||||
|
|
||||||
dispatch(fetchMarkersRequest());
|
dispatch(fetchMarkersRequest());
|
||||||
|
|
||||||
api(getState).get('/api/v1/markers', { params }).then(response => {
|
api(getState).get('/api/v1/markers', { params }).then(response => {
|
||||||
dispatch(fetchMarkersSuccess(response.data));
|
dispatch(fetchMarkersSuccess(response.data));
|
||||||
}).catch(error => {
|
}).catch(error => {
|
||||||
dispatch(fetchMarkersFail(error));
|
dispatch(fetchMarkersFail(error));
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
export function fetchMarkersRequest() {
|
export function fetchMarkersRequest() {
|
||||||
|
|
|
@ -112,7 +112,7 @@ const expandNormalizedNotifications = (state, notifications, next, isLoadingRece
|
||||||
} else {
|
} else {
|
||||||
const mostRecent = items.find(item => item !== null);
|
const mostRecent = items.find(item => item !== null);
|
||||||
if (mostRecent && compareId(lastReadId, mostRecent.get('id')) < 0) {
|
if (mostRecent && compareId(lastReadId, mostRecent.get('id')) < 0) {
|
||||||
mutable.set('lastReadId', mostRecentId);
|
mutable.set('lastReadId', mostRecent.get('id'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -129,7 +129,7 @@ const clearUnread = (state) => {
|
||||||
state = state.set('unread', state.get('pendingItems').size);
|
state = state.set('unread', state.get('pendingItems').size);
|
||||||
const lastNotification = state.get('items').find(item => item !== null);
|
const lastNotification = state.get('items').find(item => item !== null);
|
||||||
return state.set('lastReadId', lastNotification ? lastNotification.get('id') : '0');
|
return state.set('lastReadId', lastNotification ? lastNotification.get('id') : '0');
|
||||||
}
|
};
|
||||||
|
|
||||||
const updateTop = (state, top) => {
|
const updateTop = (state, top) => {
|
||||||
state = state.set('top', top);
|
state = state.set('top', top);
|
||||||
|
@ -142,8 +142,9 @@ const updateTop = (state, top) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const deleteByStatus = (state, statusId) => {
|
const deleteByStatus = (state, statusId) => {
|
||||||
|
const lastReadId = state.get('lastReadId');
|
||||||
|
|
||||||
if (shouldCountUnreadNotifications(state)) {
|
if (shouldCountUnreadNotifications(state)) {
|
||||||
const lastReadId = state.get('lastReadId');
|
|
||||||
const deletedUnread = state.get('items').filter(item => item !== null && item.get('status') === statusId && compareId(item.get('id'), lastReadId) > 0);
|
const deletedUnread = state.get('items').filter(item => item !== null && item.get('status') === statusId && compareId(item.get('id'), lastReadId) > 0);
|
||||||
state = state.update('unread', unread => unread - deletedUnread.size);
|
state = state.update('unread', unread => unread - deletedUnread.size);
|
||||||
}
|
}
|
||||||
|
@ -224,7 +225,7 @@ const recountUnread = (state, last_read_id) => {
|
||||||
mutable.set('unread', mutable.get('pendingItems').count(item => item !== null) + mutable.get('items').count(item => item && compareId(item.get('id'), last_read_id) > 0));
|
mutable.set('unread', mutable.get('pendingItems').count(item => item !== null) + mutable.get('items').count(item => item && compareId(item.get('id'), last_read_id) > 0));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
};
|
||||||
|
|
||||||
export default function notifications(state = initialState, action) {
|
export default function notifications(state = initialState, action) {
|
||||||
let st;
|
let st;
|
||||||
|
|
Loading…
Reference in New Issue