refactor: Rewrite immutablejs import statements using destructuring (#4147)
This commit is contained in:
parent
7bacdd718a
commit
cc68d1945b
28 changed files with 141 additions and 141 deletions
|
@ -15,25 +15,25 @@ import {
|
|||
ACCOUNT_BLOCK_SUCCESS,
|
||||
ACCOUNT_MUTE_SUCCESS,
|
||||
} from '../actions/accounts';
|
||||
import Immutable from 'immutable';
|
||||
import { Map as ImmutableMap, List as ImmutableList, fromJS } from 'immutable';
|
||||
|
||||
const initialState = Immutable.Map();
|
||||
const initialState = ImmutableMap();
|
||||
|
||||
const initialTimeline = Immutable.Map({
|
||||
const initialTimeline = ImmutableMap({
|
||||
unread: 0,
|
||||
online: false,
|
||||
top: true,
|
||||
loaded: false,
|
||||
isLoading: false,
|
||||
next: false,
|
||||
items: Immutable.List(),
|
||||
items: ImmutableList(),
|
||||
});
|
||||
|
||||
const normalizeTimeline = (state, timeline, statuses, next) => {
|
||||
const ids = Immutable.List(statuses.map(status => status.get('id')));
|
||||
const ids = ImmutableList(statuses.map(status => status.get('id')));
|
||||
const wasLoaded = state.getIn([timeline, 'loaded']);
|
||||
const hadNext = state.getIn([timeline, 'next']);
|
||||
const oldIds = state.getIn([timeline, 'items'], Immutable.List());
|
||||
const oldIds = state.getIn([timeline, 'items'], ImmutableList());
|
||||
|
||||
return state.update(timeline, initialTimeline, map => map.withMutations(mMap => {
|
||||
mMap.set('loaded', true);
|
||||
|
@ -44,8 +44,8 @@ const normalizeTimeline = (state, timeline, statuses, next) => {
|
|||
};
|
||||
|
||||
const appendNormalizedTimeline = (state, timeline, statuses, next) => {
|
||||
const ids = Immutable.List(statuses.map(status => status.get('id')));
|
||||
const oldIds = state.getIn([timeline, 'items'], Immutable.List());
|
||||
const ids = ImmutableList(statuses.map(status => status.get('id')));
|
||||
const oldIds = state.getIn([timeline, 'items'], ImmutableList());
|
||||
|
||||
return state.update(timeline, initialTimeline, map => map.withMutations(mMap => {
|
||||
mMap.set('isLoading', false);
|
||||
|
@ -56,7 +56,7 @@ const appendNormalizedTimeline = (state, timeline, statuses, next) => {
|
|||
|
||||
const updateTimeline = (state, timeline, status, references) => {
|
||||
const top = state.getIn([timeline, 'top']);
|
||||
const ids = state.getIn([timeline, 'items'], Immutable.List());
|
||||
const ids = state.getIn([timeline, 'items'], ImmutableList());
|
||||
const includesId = ids.includes(status.get('id'));
|
||||
const unread = state.getIn([timeline, 'unread'], 0);
|
||||
|
||||
|
@ -124,11 +124,11 @@ export default function timelines(state = initialState, action) {
|
|||
case TIMELINE_EXPAND_FAIL:
|
||||
return state.update(action.timeline, initialTimeline, map => map.set('isLoading', false));
|
||||
case TIMELINE_REFRESH_SUCCESS:
|
||||
return normalizeTimeline(state, action.timeline, Immutable.fromJS(action.statuses), action.next);
|
||||
return normalizeTimeline(state, action.timeline, fromJS(action.statuses), action.next);
|
||||
case TIMELINE_EXPAND_SUCCESS:
|
||||
return appendNormalizedTimeline(state, action.timeline, Immutable.fromJS(action.statuses), action.next);
|
||||
return appendNormalizedTimeline(state, action.timeline, fromJS(action.statuses), action.next);
|
||||
case TIMELINE_UPDATE:
|
||||
return updateTimeline(state, action.timeline, Immutable.fromJS(action.status), action.references);
|
||||
return updateTimeline(state, action.timeline, fromJS(action.status), action.references);
|
||||
case TIMELINE_DELETE:
|
||||
return deleteStatus(state, action.id, action.accountId, action.references, action.reblogOf);
|
||||
case ACCOUNT_BLOCK_SUCCESS:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue