kopia lustrzana https://gitlab.com/soapbox-pub/soapbox
Rip out markers, don't rely on them for unread count
rodzic
399c2874bb
commit
2c551130e6
|
@ -13,7 +13,6 @@ import { defineMessages } from 'react-intl';
|
||||||
import { List as ImmutableList } from 'immutable';
|
import { List as ImmutableList } from 'immutable';
|
||||||
import { unescapeHTML } from '../utils/html';
|
import { unescapeHTML } from '../utils/html';
|
||||||
import { getFilters, regexFromFilters } from '../selectors';
|
import { getFilters, regexFromFilters } from '../selectors';
|
||||||
import { fetchMarkers } from './markers';
|
|
||||||
|
|
||||||
export const NOTIFICATIONS_UPDATE = 'NOTIFICATIONS_UPDATE';
|
export const NOTIFICATIONS_UPDATE = 'NOTIFICATIONS_UPDATE';
|
||||||
export const NOTIFICATIONS_UPDATE_NOOP = 'NOTIFICATIONS_UPDATE_NOOP';
|
export const NOTIFICATIONS_UPDATE_NOOP = 'NOTIFICATIONS_UPDATE_NOOP';
|
||||||
|
@ -175,7 +174,6 @@ export function expandNotifications({ maxId } = {}, done = noOp) {
|
||||||
params.since_id = notifications.getIn(['items', 0, 'id']);
|
params.since_id = notifications.getIn(['items', 0, 'id']);
|
||||||
}
|
}
|
||||||
|
|
||||||
dispatch(fetchMarkers(['notifications']));
|
|
||||||
dispatch(expandNotificationsRequest(isLoadingMore));
|
dispatch(expandNotificationsRequest(isLoadingMore));
|
||||||
|
|
||||||
api(getState).get('/api/v1/notifications', { params }).then(response => {
|
api(getState).get('/api/v1/notifications', { params }).then(response => {
|
||||||
|
|
|
@ -1,10 +1,8 @@
|
||||||
import * as actions from 'soapbox/actions/notifications';
|
import * as actions from 'soapbox/actions/notifications';
|
||||||
import reducer from '../notifications';
|
import reducer from '../notifications';
|
||||||
import notifications from 'soapbox/__fixtures__/notifications.json';
|
import notifications from 'soapbox/__fixtures__/notifications.json';
|
||||||
import markers from 'soapbox/__fixtures__/markers.json';
|
|
||||||
import { Map as ImmutableMap, List as ImmutableList } from 'immutable';
|
import { Map as ImmutableMap, List as ImmutableList } from 'immutable';
|
||||||
import { take } from 'lodash';
|
import { take } from 'lodash';
|
||||||
import { SAVE_MARKERS_SUCCESS } from 'soapbox/actions/markers';
|
|
||||||
import { ACCOUNT_BLOCK_SUCCESS, ACCOUNT_MUTE_SUCCESS } from 'soapbox/actions/accounts';
|
import { ACCOUNT_BLOCK_SUCCESS, ACCOUNT_MUTE_SUCCESS } from 'soapbox/actions/accounts';
|
||||||
import notification from 'soapbox/__fixtures__/notification.json';
|
import notification from 'soapbox/__fixtures__/notification.json';
|
||||||
import intlMessages from 'soapbox/__fixtures__/intlMessages.json';
|
import intlMessages from 'soapbox/__fixtures__/intlMessages.json';
|
||||||
|
@ -76,21 +74,6 @@ describe('notifications reducer', () => {
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should handle SAVE_MARKERS_SUCCESS', () => {
|
|
||||||
const state = ImmutableMap({
|
|
||||||
unread: 1,
|
|
||||||
lastRead: '35098811',
|
|
||||||
});
|
|
||||||
const action = {
|
|
||||||
type: SAVE_MARKERS_SUCCESS,
|
|
||||||
markers: markers,
|
|
||||||
};
|
|
||||||
expect(reducer(state, action)).toEqual(ImmutableMap({
|
|
||||||
unread: 3,
|
|
||||||
lastRead: '35098814',
|
|
||||||
}));
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should handle NOTIFICATIONS_EXPAND_REQUEST', () => {
|
it('should handle NOTIFICATIONS_EXPAND_REQUEST', () => {
|
||||||
const state = ImmutableMap({
|
const state = ImmutableMap({
|
||||||
isLoading: false,
|
isLoading: false,
|
||||||
|
|
|
@ -15,14 +15,9 @@ import {
|
||||||
ACCOUNT_BLOCK_SUCCESS,
|
ACCOUNT_BLOCK_SUCCESS,
|
||||||
ACCOUNT_MUTE_SUCCESS,
|
ACCOUNT_MUTE_SUCCESS,
|
||||||
} from '../actions/accounts';
|
} from '../actions/accounts';
|
||||||
import {
|
|
||||||
FETCH_MARKERS_SUCCESS,
|
|
||||||
SAVE_MARKERS_SUCCESS,
|
|
||||||
} from '../actions/markers';
|
|
||||||
import { TIMELINE_DELETE, TIMELINE_DISCONNECT } from '../actions/timelines';
|
import { TIMELINE_DELETE, TIMELINE_DISCONNECT } from '../actions/timelines';
|
||||||
import { Map as ImmutableMap, List as ImmutableList } from 'immutable';
|
import { Map as ImmutableMap, List as ImmutableList } from 'immutable';
|
||||||
import compareId from '../compare_id';
|
import compareId from '../compare_id';
|
||||||
import { fromJS } from 'immutable';
|
|
||||||
import { get } from 'lodash';
|
import { get } from 'lodash';
|
||||||
|
|
||||||
const initialState = ImmutableMap({
|
const initialState = ImmutableMap({
|
||||||
|
@ -137,13 +132,6 @@ const updateNotificationsQueue = (state, notification, intlMessages, intlLocale)
|
||||||
|
|
||||||
export default function notifications(state = initialState, action) {
|
export default function notifications(state = initialState, action) {
|
||||||
switch(action.type) {
|
switch(action.type) {
|
||||||
case FETCH_MARKERS_SUCCESS:
|
|
||||||
case SAVE_MARKERS_SUCCESS:
|
|
||||||
const prevRead = state.get('lastRead');
|
|
||||||
const marker = fromJS(action.markers);
|
|
||||||
const unread = marker.getIn(['notifications', 'pleroma', 'unread_count'], state.get('unread', 0));
|
|
||||||
const lastRead = marker.getIn(['notifications', 'last_read_id'], prevRead);
|
|
||||||
return state.merge({ unread, lastRead });
|
|
||||||
case NOTIFICATIONS_EXPAND_REQUEST:
|
case NOTIFICATIONS_EXPAND_REQUEST:
|
||||||
return state.set('isLoading', true);
|
return state.set('isLoading', true);
|
||||||
case NOTIFICATIONS_EXPAND_FAIL:
|
case NOTIFICATIONS_EXPAND_FAIL:
|
||||||
|
|
Ładowanie…
Reference in New Issue