From 2c551130e6401a0cdaaaea05a0bae624a30165ad Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Fri, 28 Aug 2020 16:43:01 -0500 Subject: [PATCH] Rip out markers, don't rely on them for unread count --- app/soapbox/actions/notifications.js | 2 -- .../reducers/__tests__/notifications-test.js | 17 ----------------- app/soapbox/reducers/notifications.js | 12 ------------ 3 files changed, 31 deletions(-) diff --git a/app/soapbox/actions/notifications.js b/app/soapbox/actions/notifications.js index eb6b92aeb..1346c36c0 100644 --- a/app/soapbox/actions/notifications.js +++ b/app/soapbox/actions/notifications.js @@ -13,7 +13,6 @@ import { defineMessages } from 'react-intl'; import { List as ImmutableList } from 'immutable'; import { unescapeHTML } from '../utils/html'; import { getFilters, regexFromFilters } from '../selectors'; -import { fetchMarkers } from './markers'; export const NOTIFICATIONS_UPDATE = 'NOTIFICATIONS_UPDATE'; 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']); } - dispatch(fetchMarkers(['notifications'])); dispatch(expandNotificationsRequest(isLoadingMore)); api(getState).get('/api/v1/notifications', { params }).then(response => { diff --git a/app/soapbox/reducers/__tests__/notifications-test.js b/app/soapbox/reducers/__tests__/notifications-test.js index c12616bae..97141c756 100644 --- a/app/soapbox/reducers/__tests__/notifications-test.js +++ b/app/soapbox/reducers/__tests__/notifications-test.js @@ -1,10 +1,8 @@ import * as actions from 'soapbox/actions/notifications'; import reducer from '../notifications'; import notifications from 'soapbox/__fixtures__/notifications.json'; -import markers from 'soapbox/__fixtures__/markers.json'; import { Map as ImmutableMap, List as ImmutableList } from 'immutable'; import { take } from 'lodash'; -import { SAVE_MARKERS_SUCCESS } from 'soapbox/actions/markers'; import { ACCOUNT_BLOCK_SUCCESS, ACCOUNT_MUTE_SUCCESS } from 'soapbox/actions/accounts'; import notification from 'soapbox/__fixtures__/notification.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', () => { const state = ImmutableMap({ isLoading: false, diff --git a/app/soapbox/reducers/notifications.js b/app/soapbox/reducers/notifications.js index e49d5dc11..c4c97c73f 100644 --- a/app/soapbox/reducers/notifications.js +++ b/app/soapbox/reducers/notifications.js @@ -15,14 +15,9 @@ import { ACCOUNT_BLOCK_SUCCESS, ACCOUNT_MUTE_SUCCESS, } from '../actions/accounts'; -import { - FETCH_MARKERS_SUCCESS, - SAVE_MARKERS_SUCCESS, -} from '../actions/markers'; import { TIMELINE_DELETE, TIMELINE_DISCONNECT } from '../actions/timelines'; import { Map as ImmutableMap, List as ImmutableList } from 'immutable'; import compareId from '../compare_id'; -import { fromJS } from 'immutable'; import { get } from 'lodash'; const initialState = ImmutableMap({ @@ -137,13 +132,6 @@ const updateNotificationsQueue = (state, notification, intlMessages, intlLocale) export default function notifications(state = initialState, action) { 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: return state.set('isLoading', true); case NOTIFICATIONS_EXPAND_FAIL: