[Glitch] Do not filter the status collection after muting and blocking
Port fd87e5a53b
to glitch-soc
This commit is contained in:
parent
d55ab8e3e8
commit
f84b4d90cb
2 changed files with 13 additions and 19 deletions
|
@ -1,3 +1,7 @@
|
||||||
|
import {
|
||||||
|
ACCOUNT_BLOCK_SUCCESS,
|
||||||
|
ACCOUNT_MUTE_SUCCESS,
|
||||||
|
} from 'flavours/glitch/actions/accounts';
|
||||||
import { CONTEXT_FETCH_SUCCESS } from 'flavours/glitch/actions/statuses';
|
import { CONTEXT_FETCH_SUCCESS } from 'flavours/glitch/actions/statuses';
|
||||||
import { TIMELINE_DELETE, TIMELINE_CONTEXT_UPDATE } from 'flavours/glitch/actions/timelines';
|
import { TIMELINE_DELETE, TIMELINE_CONTEXT_UPDATE } from 'flavours/glitch/actions/timelines';
|
||||||
import { Map as ImmutableMap, List as ImmutableList } from 'immutable';
|
import { Map as ImmutableMap, List as ImmutableList } from 'immutable';
|
||||||
|
@ -31,6 +35,12 @@ const deleteFromContexts = (state, id) => {
|
||||||
return state;
|
return state;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const filterContexts = (state, relationship) => {
|
||||||
|
return state.map(
|
||||||
|
statuses => statuses.filter(
|
||||||
|
status => status.get('account') !== relationship.id));
|
||||||
|
};
|
||||||
|
|
||||||
const updateContext = (state, status, references) => {
|
const updateContext = (state, status, references) => {
|
||||||
return state.update('descendants', map => {
|
return state.update('descendants', map => {
|
||||||
references.forEach(parentId => {
|
references.forEach(parentId => {
|
||||||
|
@ -49,6 +59,9 @@ const updateContext = (state, status, references) => {
|
||||||
|
|
||||||
export default function contexts(state = initialState, action) {
|
export default function contexts(state = initialState, action) {
|
||||||
switch(action.type) {
|
switch(action.type) {
|
||||||
|
case ACCOUNT_BLOCK_SUCCESS:
|
||||||
|
case ACCOUNT_MUTE_SUCCESS:
|
||||||
|
return filterContexts(state, action.relationship);
|
||||||
case CONTEXT_FETCH_SUCCESS:
|
case CONTEXT_FETCH_SUCCESS:
|
||||||
return normalizeContext(state, action.id, action.ancestors, action.descendants);
|
return normalizeContext(state, action.id, action.ancestors, action.descendants);
|
||||||
case TIMELINE_DELETE:
|
case TIMELINE_DELETE:
|
||||||
|
|
|
@ -26,10 +26,6 @@ import {
|
||||||
TIMELINE_DELETE,
|
TIMELINE_DELETE,
|
||||||
TIMELINE_EXPAND_SUCCESS,
|
TIMELINE_EXPAND_SUCCESS,
|
||||||
} from 'flavours/glitch/actions/timelines';
|
} from 'flavours/glitch/actions/timelines';
|
||||||
import {
|
|
||||||
ACCOUNT_BLOCK_SUCCESS,
|
|
||||||
ACCOUNT_MUTE_SUCCESS,
|
|
||||||
} from 'flavours/glitch/actions/accounts';
|
|
||||||
import {
|
import {
|
||||||
NOTIFICATIONS_UPDATE,
|
NOTIFICATIONS_UPDATE,
|
||||||
NOTIFICATIONS_REFRESH_SUCCESS,
|
NOTIFICATIONS_REFRESH_SUCCESS,
|
||||||
|
@ -96,18 +92,6 @@ const deleteStatus = (state, id, references) => {
|
||||||
return state.delete(id);
|
return state.delete(id);
|
||||||
};
|
};
|
||||||
|
|
||||||
const filterStatuses = (state, relationship) => {
|
|
||||||
state.forEach(status => {
|
|
||||||
if (status.get('account') !== relationship.id) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
state = deleteStatus(state, status.get('id'), state.filter(item => item.get('reblog') === status.get('id')));
|
|
||||||
});
|
|
||||||
|
|
||||||
return state;
|
|
||||||
};
|
|
||||||
|
|
||||||
const initialState = ImmutableMap();
|
const initialState = ImmutableMap();
|
||||||
|
|
||||||
export default function statuses(state = initialState, action) {
|
export default function statuses(state = initialState, action) {
|
||||||
|
@ -155,9 +139,6 @@ export default function statuses(state = initialState, action) {
|
||||||
return normalizeStatuses(state, action.statuses);
|
return normalizeStatuses(state, action.statuses);
|
||||||
case TIMELINE_DELETE:
|
case TIMELINE_DELETE:
|
||||||
return deleteStatus(state, action.id, action.references);
|
return deleteStatus(state, action.id, action.references);
|
||||||
case ACCOUNT_BLOCK_SUCCESS:
|
|
||||||
case ACCOUNT_MUTE_SUCCESS:
|
|
||||||
return filterStatuses(state, action.relationship);
|
|
||||||
default:
|
default:
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue