Fix #2205 - Delete associated notifications when a status is deleted (#2994)

main
Eugen Rochko 2017-05-11 21:54:47 +02:00 committed by GitHub
parent 65f9db73b0
commit d0ef318eaa
1 changed files with 7 additions and 0 deletions

View File

@ -10,6 +10,7 @@ import {
NOTIFICATIONS_SCROLL_TOP NOTIFICATIONS_SCROLL_TOP
} from '../actions/notifications'; } from '../actions/notifications';
import { ACCOUNT_BLOCK_SUCCESS } from '../actions/accounts'; import { ACCOUNT_BLOCK_SUCCESS } from '../actions/accounts';
import { TIMELINE_DELETE } from '../actions/timelines';
import Immutable from 'immutable'; import Immutable from 'immutable';
const initialState = Immutable.Map({ const initialState = Immutable.Map({
@ -87,6 +88,10 @@ const updateTop = (state, top) => {
return state.set('top', top); return state.set('top', top);
}; };
const deleteByStatus = (state, statusId) => {
return state.update('items', list => list.filterNot(item => item.get('status') === statusId));
};
export default function notifications(state = initialState, action) { export default function notifications(state = initialState, action) {
switch(action.type) { switch(action.type) {
case NOTIFICATIONS_REFRESH_REQUEST: case NOTIFICATIONS_REFRESH_REQUEST:
@ -106,6 +111,8 @@ export default function notifications(state = initialState, action) {
return filterNotifications(state, action.relationship); return filterNotifications(state, action.relationship);
case NOTIFICATIONS_CLEAR: case NOTIFICATIONS_CLEAR:
return state.set('items', Immutable.List()).set('next', null); return state.set('items', Immutable.List()).set('next', null);
case TIMELINE_DELETE:
return deleteByStatus(state, action.id);
default: default:
return state; return state;
} }