mirror of
https://git.bsd.gay/fef/nyastodon.git
synced 2024-12-25 05:13:40 +01:00
Fix another mistake
This commit is contained in:
parent
44f236e889
commit
4286d49ade
1 changed files with 8 additions and 8 deletions
|
@ -19,29 +19,29 @@ const initialState = Immutable.Map({
|
||||||
favourited_by: Immutable.Map()
|
favourited_by: Immutable.Map()
|
||||||
});
|
});
|
||||||
|
|
||||||
const normalizeList = (state, type, id, accounts, prev) => {
|
const normalizeList = (state, type, id, accounts, next) => {
|
||||||
return state.setIn([type, id], Immutable.Map({
|
return state.setIn([type, id], Immutable.Map({
|
||||||
prev,
|
next,
|
||||||
items: Immutable.List(accounts.map(item => item.id))
|
items: Immutable.List(accounts.map(item => item.id))
|
||||||
}));
|
}));
|
||||||
};
|
};
|
||||||
|
|
||||||
const appendToList = (state, type, id, accounts, prev) => {
|
const appendToList = (state, type, id, accounts, next) => {
|
||||||
return state.updateIn([type, id], map => {
|
return state.updateIn([type, id], map => {
|
||||||
return map.set('prev', prev).update('items', list => list.push(...accounts.map(item => item.id)));
|
return map.set('next', next).update('items', list => list.push(...accounts.map(item => item.id)));
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
export default function userLists(state = initialState, action) {
|
export default function userLists(state = initialState, action) {
|
||||||
switch(action.type) {
|
switch(action.type) {
|
||||||
case FOLLOWERS_FETCH_SUCCESS:
|
case FOLLOWERS_FETCH_SUCCESS:
|
||||||
return normalizeList(state, 'followers', action.id, action.accounts, action.prev);
|
return normalizeList(state, 'followers', action.id, action.accounts, action.next);
|
||||||
case FOLLOWERS_EXPAND_SUCCESS:
|
case FOLLOWERS_EXPAND_SUCCESS:
|
||||||
return appendToList(state, 'followers', action.id, action.accounts, action.prev);
|
return appendToList(state, 'followers', action.id, action.accounts, action.next);
|
||||||
case FOLLOWING_FETCH_SUCCESS:
|
case FOLLOWING_FETCH_SUCCESS:
|
||||||
return normalizeList(state, 'following', action.id, action.accounts, action.prev);
|
return normalizeList(state, 'following', action.id, action.accounts, action.next);
|
||||||
case FOLLOWING_EXPAND_SUCCESS:
|
case FOLLOWING_EXPAND_SUCCESS:
|
||||||
return appendToList(state, 'following', action.id, action.accounts, action.prev);
|
return appendToList(state, 'following', action.id, action.accounts, action.next);
|
||||||
case SUGGESTIONS_FETCH_SUCCESS:
|
case SUGGESTIONS_FETCH_SUCCESS:
|
||||||
return state.set('suggestions', Immutable.List(action.accounts.map(item => item.id)));
|
return state.set('suggestions', Immutable.List(action.accounts.map(item => item.id)));
|
||||||
case REBLOGS_FETCH_SUCCESS:
|
case REBLOGS_FETCH_SUCCESS:
|
||||||
|
|
Loading…
Reference in a new issue