forked from treehouse/mastodon
refactor: Rewrite immutablejs import statements using destructuring (#4147)
parent
7bacdd718a
commit
cc68d1945b
|
@ -1,5 +1,5 @@
|
||||||
import api, { getLinks } from '../api';
|
import api, { getLinks } from '../api';
|
||||||
import Immutable from 'immutable';
|
import { List as ImmutableList } from 'immutable';
|
||||||
import IntlMessageFormat from 'intl-messageformat';
|
import IntlMessageFormat from 'intl-messageformat';
|
||||||
import { fetchRelationships } from './accounts';
|
import { fetchRelationships } from './accounts';
|
||||||
import { defineMessages } from 'react-intl';
|
import { defineMessages } from 'react-intl';
|
||||||
|
@ -124,7 +124,7 @@ export function refreshNotificationsFail(error, skipLoading) {
|
||||||
|
|
||||||
export function expandNotifications() {
|
export function expandNotifications() {
|
||||||
return (dispatch, getState) => {
|
return (dispatch, getState) => {
|
||||||
const items = getState().getIn(['notifications', 'items'], Immutable.List());
|
const items = getState().getIn(['notifications', 'items'], ImmutableList());
|
||||||
|
|
||||||
if (getState().getIn(['notifications', 'isLoading']) || items.size === 0) {
|
if (getState().getIn(['notifications', 'isLoading']) || items.size === 0) {
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
import Immutable from 'immutable';
|
import { Iterable, fromJS } from 'immutable';
|
||||||
|
|
||||||
export const STORE_HYDRATE = 'STORE_HYDRATE';
|
export const STORE_HYDRATE = 'STORE_HYDRATE';
|
||||||
export const STORE_HYDRATE_LAZY = 'STORE_HYDRATE_LAZY';
|
export const STORE_HYDRATE_LAZY = 'STORE_HYDRATE_LAZY';
|
||||||
|
|
||||||
const convertState = rawState =>
|
const convertState = rawState =>
|
||||||
Immutable.fromJS(rawState, (k, v) =>
|
fromJS(rawState, (k, v) =>
|
||||||
Immutable.Iterable.isIndexed(v) ? v.toList() : v.toMap().mapKeys(x =>
|
Iterable.isIndexed(v) ? v.toList() : v.toMap().mapKeys(x =>
|
||||||
Number.isNaN(x * 1) ? x : x * 1));
|
Number.isNaN(x * 1) ? x : x * 1));
|
||||||
|
|
||||||
export function hydrateStore(rawState) {
|
export function hydrateStore(rawState) {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import api, { getLinks } from '../api';
|
import api, { getLinks } from '../api';
|
||||||
import Immutable from 'immutable';
|
import { Map as ImmutableMap, List as ImmutableList } from 'immutable';
|
||||||
|
|
||||||
export const TIMELINE_UPDATE = 'TIMELINE_UPDATE';
|
export const TIMELINE_UPDATE = 'TIMELINE_UPDATE';
|
||||||
export const TIMELINE_DELETE = 'TIMELINE_DELETE';
|
export const TIMELINE_DELETE = 'TIMELINE_DELETE';
|
||||||
|
@ -66,13 +66,13 @@ export function refreshTimelineRequest(timeline, skipLoading) {
|
||||||
|
|
||||||
export function refreshTimeline(timelineId, path, params = {}) {
|
export function refreshTimeline(timelineId, path, params = {}) {
|
||||||
return function (dispatch, getState) {
|
return function (dispatch, getState) {
|
||||||
const timeline = getState().getIn(['timelines', timelineId], Immutable.Map());
|
const timeline = getState().getIn(['timelines', timelineId], ImmutableMap());
|
||||||
|
|
||||||
if (timeline.get('isLoading') || timeline.get('online')) {
|
if (timeline.get('isLoading') || timeline.get('online')) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const ids = timeline.get('items', Immutable.List());
|
const ids = timeline.get('items', ImmutableList());
|
||||||
const newestId = ids.size > 0 ? ids.first() : null;
|
const newestId = ids.size > 0 ? ids.first() : null;
|
||||||
|
|
||||||
let skipLoading = timeline.get('loaded');
|
let skipLoading = timeline.get('loaded');
|
||||||
|
@ -111,8 +111,8 @@ export function refreshTimelineFail(timeline, error, skipLoading) {
|
||||||
|
|
||||||
export function expandTimeline(timelineId, path, params = {}) {
|
export function expandTimeline(timelineId, path, params = {}) {
|
||||||
return (dispatch, getState) => {
|
return (dispatch, getState) => {
|
||||||
const timeline = getState().getIn(['timelines', timelineId], Immutable.Map());
|
const timeline = getState().getIn(['timelines', timelineId], ImmutableMap());
|
||||||
const ids = timeline.get('items', Immutable.List());
|
const ids = timeline.get('items', ImmutableList());
|
||||||
|
|
||||||
if (timeline.get('isLoading') || ids.size === 0) {
|
if (timeline.get('isLoading') || ids.size === 0) {
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -9,11 +9,11 @@ import LoadingIndicator from '../../components/loading_indicator';
|
||||||
import Column from '../ui/components/column';
|
import Column from '../ui/components/column';
|
||||||
import HeaderContainer from './containers/header_container';
|
import HeaderContainer from './containers/header_container';
|
||||||
import ColumnBackButton from '../../components/column_back_button';
|
import ColumnBackButton from '../../components/column_back_button';
|
||||||
import Immutable from 'immutable';
|
import { List as ImmutableList } from 'immutable';
|
||||||
import ImmutablePureComponent from 'react-immutable-pure-component';
|
import ImmutablePureComponent from 'react-immutable-pure-component';
|
||||||
|
|
||||||
const mapStateToProps = (state, props) => ({
|
const mapStateToProps = (state, props) => ({
|
||||||
statusIds: state.getIn(['timelines', `account:${Number(props.params.accountId)}`, 'items'], Immutable.List()),
|
statusIds: state.getIn(['timelines', `account:${Number(props.params.accountId)}`, 'items'], ImmutableList()),
|
||||||
isLoading: state.getIn(['timelines', `account:${Number(props.params.accountId)}`, 'isLoading']),
|
isLoading: state.getIn(['timelines', `account:${Number(props.params.accountId)}`, 'isLoading']),
|
||||||
hasMore: !!state.getIn(['timelines', `account:${Number(props.params.accountId)}`, 'next']),
|
hasMore: !!state.getIn(['timelines', `account:${Number(props.params.accountId)}`, 'next']),
|
||||||
me: state.getIn(['meta', 'me']),
|
me: state.getIn(['meta', 'me']),
|
||||||
|
|
|
@ -11,7 +11,7 @@ import { ScrollContainer } from 'react-router-scroll';
|
||||||
import { defineMessages, injectIntl, FormattedMessage } from 'react-intl';
|
import { defineMessages, injectIntl, FormattedMessage } from 'react-intl';
|
||||||
import ColumnSettingsContainer from './containers/column_settings_container';
|
import ColumnSettingsContainer from './containers/column_settings_container';
|
||||||
import { createSelector } from 'reselect';
|
import { createSelector } from 'reselect';
|
||||||
import Immutable from 'immutable';
|
import { List as ImmutableList } from 'immutable';
|
||||||
import LoadMore from '../../components/load_more';
|
import LoadMore from '../../components/load_more';
|
||||||
import { debounce } from 'lodash';
|
import { debounce } from 'lodash';
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@ const messages = defineMessages({
|
||||||
});
|
});
|
||||||
|
|
||||||
const getNotifications = createSelector([
|
const getNotifications = createSelector([
|
||||||
state => Immutable.List(state.getIn(['settings', 'notifications', 'shows']).filter(item => !item).keys()),
|
state => ImmutableList(state.getIn(['settings', 'notifications', 'shows']).filter(item => !item).keys()),
|
||||||
state => state.getIn(['notifications', 'items']),
|
state => state.getIn(['notifications', 'items']),
|
||||||
], (excludedTypes, notifications) => notifications.filterNot(item => excludedTypes.includes(item.get('type'))));
|
], (excludedTypes, notifications) => notifications.filterNot(item => excludedTypes.includes(item.get('type'))));
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
import StatusCheckBox from '../components/status_check_box';
|
import StatusCheckBox from '../components/status_check_box';
|
||||||
import { toggleStatusReport } from '../../../actions/reports';
|
import { toggleStatusReport } from '../../../actions/reports';
|
||||||
import Immutable from 'immutable';
|
import { Set as ImmutableSet } from 'immutable';
|
||||||
|
|
||||||
const mapStateToProps = (state, { id }) => ({
|
const mapStateToProps = (state, { id }) => ({
|
||||||
status: state.getIn(['statuses', id]),
|
status: state.getIn(['statuses', id]),
|
||||||
checked: state.getIn(['reports', 'new', 'status_ids'], Immutable.Set()).includes(id),
|
checked: state.getIn(['reports', 'new', 'status_ids'], ImmutableSet()).includes(id),
|
||||||
});
|
});
|
||||||
|
|
||||||
const mapDispatchToProps = (dispatch, { id }) => ({
|
const mapDispatchToProps = (dispatch, { id }) => ({
|
||||||
|
|
|
@ -10,7 +10,7 @@ import ComposeForm from '../../compose/components/compose_form';
|
||||||
import Search from '../../compose/components/search';
|
import Search from '../../compose/components/search';
|
||||||
import NavigationBar from '../../compose/components/navigation_bar';
|
import NavigationBar from '../../compose/components/navigation_bar';
|
||||||
import ColumnHeader from './column_header';
|
import ColumnHeader from './column_header';
|
||||||
import Immutable from 'immutable';
|
import { List as ImmutableList } from 'immutable';
|
||||||
|
|
||||||
const noop = () => { };
|
const noop = () => { };
|
||||||
|
|
||||||
|
@ -48,7 +48,7 @@ const PageTwo = ({ me }) => (
|
||||||
</div>
|
</div>
|
||||||
<ComposeForm
|
<ComposeForm
|
||||||
text='Awoo! #introductions'
|
text='Awoo! #introductions'
|
||||||
suggestions={Immutable.List()}
|
suggestions={ImmutableList()}
|
||||||
mentionedDomains={[]}
|
mentionedDomains={[]}
|
||||||
spoiler={false}
|
spoiler={false}
|
||||||
onChange={noop}
|
onChange={noop}
|
||||||
|
|
|
@ -7,7 +7,7 @@ import ImmutablePropTypes from 'react-immutable-proptypes';
|
||||||
import { makeGetAccount } from '../../../selectors';
|
import { makeGetAccount } from '../../../selectors';
|
||||||
import { defineMessages, FormattedMessage, injectIntl } from 'react-intl';
|
import { defineMessages, FormattedMessage, injectIntl } from 'react-intl';
|
||||||
import StatusCheckBox from '../../report/containers/status_check_box_container';
|
import StatusCheckBox from '../../report/containers/status_check_box_container';
|
||||||
import Immutable from 'immutable';
|
import { OrderedSet } from 'immutable';
|
||||||
import ImmutablePureComponent from 'react-immutable-pure-component';
|
import ImmutablePureComponent from 'react-immutable-pure-component';
|
||||||
import Button from '../../../components/button';
|
import Button from '../../../components/button';
|
||||||
|
|
||||||
|
@ -26,7 +26,7 @@ const makeMapStateToProps = () => {
|
||||||
isSubmitting: state.getIn(['reports', 'new', 'isSubmitting']),
|
isSubmitting: state.getIn(['reports', 'new', 'isSubmitting']),
|
||||||
account: getAccount(state, accountId),
|
account: getAccount(state, accountId),
|
||||||
comment: state.getIn(['reports', 'new', 'comment']),
|
comment: state.getIn(['reports', 'new', 'comment']),
|
||||||
statusIds: Immutable.OrderedSet(state.getIn(['timelines', `account:${accountId}`, 'items'])).union(state.getIn(['reports', 'new', 'status_ids'])),
|
statusIds: OrderedSet(state.getIn(['timelines', `account:${accountId}`, 'items'])).union(state.getIn(['reports', 'new', 'status_ids'])),
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
import StatusList from '../../../components/status_list';
|
import StatusList from '../../../components/status_list';
|
||||||
import { scrollTopTimeline } from '../../../actions/timelines';
|
import { scrollTopTimeline } from '../../../actions/timelines';
|
||||||
import Immutable from 'immutable';
|
import { Map as ImmutableMap, List as ImmutableList } from 'immutable';
|
||||||
import { createSelector } from 'reselect';
|
import { createSelector } from 'reselect';
|
||||||
import { debounce } from 'lodash';
|
import { debounce } from 'lodash';
|
||||||
|
|
||||||
const makeGetStatusIds = () => createSelector([
|
const makeGetStatusIds = () => createSelector([
|
||||||
(state, { type }) => state.getIn(['settings', type], Immutable.Map()),
|
(state, { type }) => state.getIn(['settings', type], ImmutableMap()),
|
||||||
(state, { type }) => state.getIn(['timelines', type, 'items'], Immutable.List()),
|
(state, { type }) => state.getIn(['timelines', type, 'items'], ImmutableList()),
|
||||||
(state) => state.get('statuses'),
|
(state) => state.get('statuses'),
|
||||||
(state) => state.getIn(['meta', 'me']),
|
(state) => state.getIn(['meta', 'me']),
|
||||||
], (columnSettings, statusIds, statuses, me) => statusIds.filter(id => {
|
], (columnSettings, statusIds, statuses, me) => statusIds.filter(id => {
|
||||||
|
|
|
@ -44,7 +44,7 @@ import {
|
||||||
FAVOURITED_STATUSES_EXPAND_SUCCESS,
|
FAVOURITED_STATUSES_EXPAND_SUCCESS,
|
||||||
} from '../actions/favourites';
|
} from '../actions/favourites';
|
||||||
import { STORE_HYDRATE } from '../actions/store';
|
import { STORE_HYDRATE } from '../actions/store';
|
||||||
import Immutable from 'immutable';
|
import { Map as ImmutableMap, fromJS } from 'immutable';
|
||||||
|
|
||||||
const normalizeAccount = (state, account) => {
|
const normalizeAccount = (state, account) => {
|
||||||
account = { ...account };
|
account = { ...account };
|
||||||
|
@ -53,7 +53,7 @@ const normalizeAccount = (state, account) => {
|
||||||
delete account.following_count;
|
delete account.following_count;
|
||||||
delete account.statuses_count;
|
delete account.statuses_count;
|
||||||
|
|
||||||
return state.set(account.id, Immutable.fromJS(account));
|
return state.set(account.id, fromJS(account));
|
||||||
};
|
};
|
||||||
|
|
||||||
const normalizeAccounts = (state, accounts) => {
|
const normalizeAccounts = (state, accounts) => {
|
||||||
|
@ -82,7 +82,7 @@ const normalizeAccountsFromStatuses = (state, statuses) => {
|
||||||
return state;
|
return state;
|
||||||
};
|
};
|
||||||
|
|
||||||
const initialState = Immutable.Map();
|
const initialState = ImmutableMap();
|
||||||
|
|
||||||
export default function accounts(state = initialState, action) {
|
export default function accounts(state = initialState, action) {
|
||||||
switch(action.type) {
|
switch(action.type) {
|
||||||
|
|
|
@ -46,9 +46,9 @@ import {
|
||||||
FAVOURITED_STATUSES_EXPAND_SUCCESS,
|
FAVOURITED_STATUSES_EXPAND_SUCCESS,
|
||||||
} from '../actions/favourites';
|
} from '../actions/favourites';
|
||||||
import { STORE_HYDRATE } from '../actions/store';
|
import { STORE_HYDRATE } from '../actions/store';
|
||||||
import Immutable from 'immutable';
|
import { Map as ImmutableMap, fromJS } from 'immutable';
|
||||||
|
|
||||||
const normalizeAccount = (state, account) => state.set(account.id, Immutable.fromJS({
|
const normalizeAccount = (state, account) => state.set(account.id, fromJS({
|
||||||
followers_count: account.followers_count,
|
followers_count: account.followers_count,
|
||||||
following_count: account.following_count,
|
following_count: account.following_count,
|
||||||
statuses_count: account.statuses_count,
|
statuses_count: account.statuses_count,
|
||||||
|
@ -80,12 +80,12 @@ const normalizeAccountsFromStatuses = (state, statuses) => {
|
||||||
return state;
|
return state;
|
||||||
};
|
};
|
||||||
|
|
||||||
const initialState = Immutable.Map();
|
const initialState = ImmutableMap();
|
||||||
|
|
||||||
export default function accountsCounters(state = initialState, action) {
|
export default function accountsCounters(state = initialState, action) {
|
||||||
switch(action.type) {
|
switch(action.type) {
|
||||||
case STORE_HYDRATE:
|
case STORE_HYDRATE:
|
||||||
return state.merge(action.state.get('accounts').map(item => Immutable.fromJS({
|
return state.merge(action.state.get('accounts').map(item => fromJS({
|
||||||
followers_count: item.get('followers_count'),
|
followers_count: item.get('followers_count'),
|
||||||
following_count: item.get('following_count'),
|
following_count: item.get('following_count'),
|
||||||
statuses_count: item.get('statuses_count'),
|
statuses_count: item.get('statuses_count'),
|
||||||
|
|
|
@ -3,14 +3,14 @@ import {
|
||||||
ALERT_DISMISS,
|
ALERT_DISMISS,
|
||||||
ALERT_CLEAR,
|
ALERT_CLEAR,
|
||||||
} from '../actions/alerts';
|
} from '../actions/alerts';
|
||||||
import Immutable from 'immutable';
|
import { Map as ImmutableMap, List as ImmutableList } from 'immutable';
|
||||||
|
|
||||||
const initialState = Immutable.List([]);
|
const initialState = ImmutableList([]);
|
||||||
|
|
||||||
export default function alerts(state = initialState, action) {
|
export default function alerts(state = initialState, action) {
|
||||||
switch(action.type) {
|
switch(action.type) {
|
||||||
case ALERT_SHOW:
|
case ALERT_SHOW:
|
||||||
return state.push(Immutable.Map({
|
return state.push(ImmutableMap({
|
||||||
key: state.size > 0 ? state.last().get('key') + 1 : 0,
|
key: state.size > 0 ? state.last().get('key') + 1 : 0,
|
||||||
title: action.title,
|
title: action.title,
|
||||||
message: action.message,
|
message: action.message,
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
import { STATUS_CARD_FETCH_SUCCESS } from '../actions/cards';
|
import { STATUS_CARD_FETCH_SUCCESS } from '../actions/cards';
|
||||||
|
|
||||||
import Immutable from 'immutable';
|
import { Map as ImmutableMap, fromJS } from 'immutable';
|
||||||
|
|
||||||
const initialState = Immutable.Map();
|
const initialState = ImmutableMap();
|
||||||
|
|
||||||
export default function cards(state = initialState, action) {
|
export default function cards(state = initialState, action) {
|
||||||
switch(action.type) {
|
switch(action.type) {
|
||||||
case STATUS_CARD_FETCH_SUCCESS:
|
case STATUS_CARD_FETCH_SUCCESS:
|
||||||
return state.set(action.id, Immutable.fromJS(action.card));
|
return state.set(action.id, fromJS(action.card));
|
||||||
default:
|
default:
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,10 +24,10 @@ import {
|
||||||
} from '../actions/compose';
|
} from '../actions/compose';
|
||||||
import { TIMELINE_DELETE } from '../actions/timelines';
|
import { TIMELINE_DELETE } from '../actions/timelines';
|
||||||
import { STORE_HYDRATE } from '../actions/store';
|
import { STORE_HYDRATE } from '../actions/store';
|
||||||
import Immutable from 'immutable';
|
import { Map as ImmutableMap, List as ImmutableList, OrderedSet as ImmutableOrderedSet, fromJS } from 'immutable';
|
||||||
import uuid from '../uuid';
|
import uuid from '../uuid';
|
||||||
|
|
||||||
const initialState = Immutable.Map({
|
const initialState = ImmutableMap({
|
||||||
mounted: false,
|
mounted: false,
|
||||||
sensitive: false,
|
sensitive: false,
|
||||||
spoiler: false,
|
spoiler: false,
|
||||||
|
@ -40,9 +40,9 @@ const initialState = Immutable.Map({
|
||||||
is_submitting: false,
|
is_submitting: false,
|
||||||
is_uploading: false,
|
is_uploading: false,
|
||||||
progress: 0,
|
progress: 0,
|
||||||
media_attachments: Immutable.List(),
|
media_attachments: ImmutableList(),
|
||||||
suggestion_token: null,
|
suggestion_token: null,
|
||||||
suggestions: Immutable.List(),
|
suggestions: ImmutableList(),
|
||||||
me: null,
|
me: null,
|
||||||
default_privacy: 'public',
|
default_privacy: 'public',
|
||||||
default_sensitive: false,
|
default_sensitive: false,
|
||||||
|
@ -51,7 +51,7 @@ const initialState = Immutable.Map({
|
||||||
});
|
});
|
||||||
|
|
||||||
function statusToTextMentions(state, status) {
|
function statusToTextMentions(state, status) {
|
||||||
let set = Immutable.OrderedSet([]);
|
let set = ImmutableOrderedSet([]);
|
||||||
let me = state.get('me');
|
let me = state.get('me');
|
||||||
|
|
||||||
if (status.getIn(['account', 'id']) !== me) {
|
if (status.getIn(['account', 'id']) !== me) {
|
||||||
|
@ -111,7 +111,7 @@ const insertSuggestion = (state, position, token, completion) => {
|
||||||
return state.withMutations(map => {
|
return state.withMutations(map => {
|
||||||
map.update('text', oldText => `${oldText.slice(0, position)}${completion} ${oldText.slice(position + token.length)}`);
|
map.update('text', oldText => `${oldText.slice(0, position)}${completion} ${oldText.slice(position + token.length)}`);
|
||||||
map.set('suggestion_token', null);
|
map.set('suggestion_token', null);
|
||||||
map.update('suggestions', Immutable.List(), list => list.clear());
|
map.update('suggestions', ImmutableList(), list => list.clear());
|
||||||
map.set('focusDate', new Date());
|
map.set('focusDate', new Date());
|
||||||
map.set('idempotencyKey', uuid());
|
map.set('idempotencyKey', uuid());
|
||||||
});
|
});
|
||||||
|
@ -206,7 +206,7 @@ export default function compose(state = initialState, action) {
|
||||||
map.set('is_uploading', true);
|
map.set('is_uploading', true);
|
||||||
});
|
});
|
||||||
case COMPOSE_UPLOAD_SUCCESS:
|
case COMPOSE_UPLOAD_SUCCESS:
|
||||||
return appendMedia(state, Immutable.fromJS(action.media));
|
return appendMedia(state, fromJS(action.media));
|
||||||
case COMPOSE_UPLOAD_FAIL:
|
case COMPOSE_UPLOAD_FAIL:
|
||||||
return state.set('is_uploading', false);
|
return state.set('is_uploading', false);
|
||||||
case COMPOSE_UPLOAD_UNDO:
|
case COMPOSE_UPLOAD_UNDO:
|
||||||
|
@ -219,9 +219,9 @@ export default function compose(state = initialState, action) {
|
||||||
.set('focusDate', new Date())
|
.set('focusDate', new Date())
|
||||||
.set('idempotencyKey', uuid());
|
.set('idempotencyKey', uuid());
|
||||||
case COMPOSE_SUGGESTIONS_CLEAR:
|
case COMPOSE_SUGGESTIONS_CLEAR:
|
||||||
return state.update('suggestions', Immutable.List(), list => list.clear()).set('suggestion_token', null);
|
return state.update('suggestions', ImmutableList(), list => list.clear()).set('suggestion_token', null);
|
||||||
case COMPOSE_SUGGESTIONS_READY:
|
case COMPOSE_SUGGESTIONS_READY:
|
||||||
return state.set('suggestions', Immutable.List(action.accounts.map(item => item.id))).set('suggestion_token', action.token);
|
return state.set('suggestions', ImmutableList(action.accounts.map(item => item.id))).set('suggestion_token', action.token);
|
||||||
case COMPOSE_SUGGESTION_SELECT:
|
case COMPOSE_SUGGESTION_SELECT:
|
||||||
return insertSuggestion(state, action.position, action.token, action.completion);
|
return insertSuggestion(state, action.position, action.token, action.completion);
|
||||||
case TIMELINE_DELETE:
|
case TIMELINE_DELETE:
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
import { CONTEXT_FETCH_SUCCESS } from '../actions/statuses';
|
import { CONTEXT_FETCH_SUCCESS } from '../actions/statuses';
|
||||||
import { TIMELINE_DELETE } from '../actions/timelines';
|
import { TIMELINE_DELETE } from '../actions/timelines';
|
||||||
import Immutable from 'immutable';
|
import { Map as ImmutableMap, List as ImmutableList, fromJS } from 'immutable';
|
||||||
|
|
||||||
const initialState = Immutable.Map({
|
const initialState = ImmutableMap({
|
||||||
ancestors: Immutable.Map(),
|
ancestors: ImmutableMap(),
|
||||||
descendants: Immutable.Map(),
|
descendants: ImmutableMap(),
|
||||||
});
|
});
|
||||||
|
|
||||||
const normalizeContext = (state, id, ancestors, descendants) => {
|
const normalizeContext = (state, id, ancestors, descendants) => {
|
||||||
|
@ -18,12 +18,12 @@ const normalizeContext = (state, id, ancestors, descendants) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const deleteFromContexts = (state, id) => {
|
const deleteFromContexts = (state, id) => {
|
||||||
state.getIn(['descendants', id], Immutable.List()).forEach(descendantId => {
|
state.getIn(['descendants', id], ImmutableList()).forEach(descendantId => {
|
||||||
state = state.updateIn(['ancestors', descendantId], Immutable.List(), list => list.filterNot(itemId => itemId === id));
|
state = state.updateIn(['ancestors', descendantId], ImmutableList(), list => list.filterNot(itemId => itemId === id));
|
||||||
});
|
});
|
||||||
|
|
||||||
state.getIn(['ancestors', id], Immutable.List()).forEach(ancestorId => {
|
state.getIn(['ancestors', id], ImmutableList()).forEach(ancestorId => {
|
||||||
state = state.updateIn(['descendants', ancestorId], Immutable.List(), list => list.filterNot(itemId => itemId === id));
|
state = state.updateIn(['descendants', ancestorId], ImmutableList(), list => list.filterNot(itemId => itemId === id));
|
||||||
});
|
});
|
||||||
|
|
||||||
state = state.deleteIn(['descendants', id]).deleteIn(['ancestors', id]);
|
state = state.deleteIn(['descendants', id]).deleteIn(['ancestors', id]);
|
||||||
|
@ -34,7 +34,7 @@ const deleteFromContexts = (state, id) => {
|
||||||
export default function contexts(state = initialState, action) {
|
export default function contexts(state = initialState, action) {
|
||||||
switch(action.type) {
|
switch(action.type) {
|
||||||
case CONTEXT_FETCH_SUCCESS:
|
case CONTEXT_FETCH_SUCCESS:
|
||||||
return normalizeContext(state, action.id, Immutable.fromJS(action.ancestors), Immutable.fromJS(action.descendants));
|
return normalizeContext(state, action.id, fromJS(action.ancestors), fromJS(action.descendants));
|
||||||
case TIMELINE_DELETE:
|
case TIMELINE_DELETE:
|
||||||
return deleteFromContexts(state, action.id);
|
return deleteFromContexts(state, action.id);
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import { STORE_HYDRATE } from '../actions/store';
|
import { STORE_HYDRATE } from '../actions/store';
|
||||||
import Immutable from 'immutable';
|
import { Map as ImmutableMap } from 'immutable';
|
||||||
|
|
||||||
const initialState = Immutable.Map({
|
const initialState = ImmutableMap({
|
||||||
accept_content_types: [],
|
accept_content_types: [],
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import { STORE_HYDRATE } from '../actions/store';
|
import { STORE_HYDRATE } from '../actions/store';
|
||||||
import Immutable from 'immutable';
|
import { Map as ImmutableMap } from 'immutable';
|
||||||
|
|
||||||
const initialState = Immutable.Map({
|
const initialState = ImmutableMap({
|
||||||
streaming_api_base_url: null,
|
streaming_api_base_url: null,
|
||||||
access_token: null,
|
access_token: null,
|
||||||
me: null,
|
me: null,
|
||||||
|
|
|
@ -11,10 +11,10 @@ import {
|
||||||
} 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 { TIMELINE_DELETE } from '../actions/timelines';
|
||||||
import Immutable from 'immutable';
|
import { Map as ImmutableMap, List as ImmutableList } from 'immutable';
|
||||||
|
|
||||||
const initialState = Immutable.Map({
|
const initialState = ImmutableMap({
|
||||||
items: Immutable.List(),
|
items: ImmutableList(),
|
||||||
next: null,
|
next: null,
|
||||||
top: true,
|
top: true,
|
||||||
unread: 0,
|
unread: 0,
|
||||||
|
@ -22,7 +22,7 @@ const initialState = Immutable.Map({
|
||||||
isLoading: true,
|
isLoading: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
const notificationToMap = notification => Immutable.Map({
|
const notificationToMap = notification => ImmutableMap({
|
||||||
id: notification.id,
|
id: notification.id,
|
||||||
type: notification.type,
|
type: notification.type,
|
||||||
account: notification.account.id,
|
account: notification.account.id,
|
||||||
|
@ -46,7 +46,7 @@ const normalizeNotification = (state, notification) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const normalizeNotifications = (state, notifications, next) => {
|
const normalizeNotifications = (state, notifications, next) => {
|
||||||
let items = Immutable.List();
|
let items = ImmutableList();
|
||||||
const loaded = state.get('loaded');
|
const loaded = state.get('loaded');
|
||||||
|
|
||||||
notifications.forEach((n, i) => {
|
notifications.forEach((n, i) => {
|
||||||
|
@ -64,7 +64,7 @@ const normalizeNotifications = (state, notifications, next) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const appendNormalizedNotifications = (state, notifications, next) => {
|
const appendNormalizedNotifications = (state, notifications, next) => {
|
||||||
let items = Immutable.List();
|
let items = ImmutableList();
|
||||||
|
|
||||||
notifications.forEach((n, i) => {
|
notifications.forEach((n, i) => {
|
||||||
items = items.set(i, notificationToMap(n));
|
items = items.set(i, notificationToMap(n));
|
||||||
|
@ -110,7 +110,7 @@ export default function notifications(state = initialState, action) {
|
||||||
case ACCOUNT_BLOCK_SUCCESS:
|
case ACCOUNT_BLOCK_SUCCESS:
|
||||||
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', ImmutableList()).set('next', null);
|
||||||
case TIMELINE_DELETE:
|
case TIMELINE_DELETE:
|
||||||
return deleteByStatus(state, action.id);
|
return deleteByStatus(state, action.id);
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -11,9 +11,9 @@ import {
|
||||||
DOMAIN_BLOCK_SUCCESS,
|
DOMAIN_BLOCK_SUCCESS,
|
||||||
DOMAIN_UNBLOCK_SUCCESS,
|
DOMAIN_UNBLOCK_SUCCESS,
|
||||||
} from '../actions/domain_blocks';
|
} from '../actions/domain_blocks';
|
||||||
import Immutable from 'immutable';
|
import { Map as ImmutableMap, fromJS } from 'immutable';
|
||||||
|
|
||||||
const normalizeRelationship = (state, relationship) => state.set(relationship.id, Immutable.fromJS(relationship));
|
const normalizeRelationship = (state, relationship) => state.set(relationship.id, fromJS(relationship));
|
||||||
|
|
||||||
const normalizeRelationships = (state, relationships) => {
|
const normalizeRelationships = (state, relationships) => {
|
||||||
relationships.forEach(relationship => {
|
relationships.forEach(relationship => {
|
||||||
|
@ -23,7 +23,7 @@ const normalizeRelationships = (state, relationships) => {
|
||||||
return state;
|
return state;
|
||||||
};
|
};
|
||||||
|
|
||||||
const initialState = Immutable.Map();
|
const initialState = ImmutableMap();
|
||||||
|
|
||||||
export default function relationships(state = initialState, action) {
|
export default function relationships(state = initialState, action) {
|
||||||
switch(action.type) {
|
switch(action.type) {
|
||||||
|
|
|
@ -7,13 +7,13 @@ import {
|
||||||
REPORT_STATUS_TOGGLE,
|
REPORT_STATUS_TOGGLE,
|
||||||
REPORT_COMMENT_CHANGE,
|
REPORT_COMMENT_CHANGE,
|
||||||
} from '../actions/reports';
|
} from '../actions/reports';
|
||||||
import Immutable from 'immutable';
|
import { Map as ImmutableMap, Set as ImmutableSet } from 'immutable';
|
||||||
|
|
||||||
const initialState = Immutable.Map({
|
const initialState = ImmutableMap({
|
||||||
new: Immutable.Map({
|
new: ImmutableMap({
|
||||||
isSubmitting: false,
|
isSubmitting: false,
|
||||||
account_id: null,
|
account_id: null,
|
||||||
status_ids: Immutable.Set(),
|
status_ids: ImmutableSet(),
|
||||||
comment: '',
|
comment: '',
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
|
@ -26,14 +26,14 @@ export default function reports(state = initialState, action) {
|
||||||
map.setIn(['new', 'account_id'], action.account.get('id'));
|
map.setIn(['new', 'account_id'], action.account.get('id'));
|
||||||
|
|
||||||
if (state.getIn(['new', 'account_id']) !== action.account.get('id')) {
|
if (state.getIn(['new', 'account_id']) !== action.account.get('id')) {
|
||||||
map.setIn(['new', 'status_ids'], action.status ? Immutable.Set([action.status.getIn(['reblog', 'id'], action.status.get('id'))]) : Immutable.Set());
|
map.setIn(['new', 'status_ids'], action.status ? ImmutableSet([action.status.getIn(['reblog', 'id'], action.status.get('id'))]) : ImmutableSet());
|
||||||
map.setIn(['new', 'comment'], '');
|
map.setIn(['new', 'comment'], '');
|
||||||
} else {
|
} else {
|
||||||
map.updateIn(['new', 'status_ids'], Immutable.Set(), set => set.add(action.status.getIn(['reblog', 'id'], action.status.get('id'))));
|
map.updateIn(['new', 'status_ids'], ImmutableSet(), set => set.add(action.status.getIn(['reblog', 'id'], action.status.get('id'))));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
case REPORT_STATUS_TOGGLE:
|
case REPORT_STATUS_TOGGLE:
|
||||||
return state.updateIn(['new', 'status_ids'], Immutable.Set(), set => {
|
return state.updateIn(['new', 'status_ids'], ImmutableSet(), set => {
|
||||||
if (action.checked) {
|
if (action.checked) {
|
||||||
return set.add(action.statusId);
|
return set.add(action.statusId);
|
||||||
}
|
}
|
||||||
|
@ -50,7 +50,7 @@ export default function reports(state = initialState, action) {
|
||||||
case REPORT_SUBMIT_SUCCESS:
|
case REPORT_SUBMIT_SUCCESS:
|
||||||
return state.withMutations(map => {
|
return state.withMutations(map => {
|
||||||
map.setIn(['new', 'account_id'], null);
|
map.setIn(['new', 'account_id'], null);
|
||||||
map.setIn(['new', 'status_ids'], Immutable.Set());
|
map.setIn(['new', 'status_ids'], ImmutableSet());
|
||||||
map.setIn(['new', 'comment'], '');
|
map.setIn(['new', 'comment'], '');
|
||||||
map.setIn(['new', 'isSubmitting'], false);
|
map.setIn(['new', 'isSubmitting'], false);
|
||||||
});
|
});
|
||||||
|
|
|
@ -5,13 +5,13 @@ import {
|
||||||
SEARCH_SHOW,
|
SEARCH_SHOW,
|
||||||
} from '../actions/search';
|
} from '../actions/search';
|
||||||
import { COMPOSE_MENTION, COMPOSE_REPLY } from '../actions/compose';
|
import { COMPOSE_MENTION, COMPOSE_REPLY } from '../actions/compose';
|
||||||
import Immutable from 'immutable';
|
import { Map as ImmutableMap, List as ImmutableList } from 'immutable';
|
||||||
|
|
||||||
const initialState = Immutable.Map({
|
const initialState = ImmutableMap({
|
||||||
value: '',
|
value: '',
|
||||||
submitted: false,
|
submitted: false,
|
||||||
hidden: false,
|
hidden: false,
|
||||||
results: Immutable.Map(),
|
results: ImmutableMap(),
|
||||||
});
|
});
|
||||||
|
|
||||||
export default function search(state = initialState, action) {
|
export default function search(state = initialState, action) {
|
||||||
|
@ -21,7 +21,7 @@ export default function search(state = initialState, action) {
|
||||||
case SEARCH_CLEAR:
|
case SEARCH_CLEAR:
|
||||||
return state.withMutations(map => {
|
return state.withMutations(map => {
|
||||||
map.set('value', '');
|
map.set('value', '');
|
||||||
map.set('results', Immutable.Map());
|
map.set('results', ImmutableMap());
|
||||||
map.set('submitted', false);
|
map.set('submitted', false);
|
||||||
map.set('hidden', false);
|
map.set('hidden', false);
|
||||||
});
|
});
|
||||||
|
@ -31,10 +31,10 @@ export default function search(state = initialState, action) {
|
||||||
case COMPOSE_MENTION:
|
case COMPOSE_MENTION:
|
||||||
return state.set('hidden', true);
|
return state.set('hidden', true);
|
||||||
case SEARCH_FETCH_SUCCESS:
|
case SEARCH_FETCH_SUCCESS:
|
||||||
return state.set('results', Immutable.Map({
|
return state.set('results', ImmutableMap({
|
||||||
accounts: Immutable.List(action.results.accounts.map(item => item.id)),
|
accounts: ImmutableList(action.results.accounts.map(item => item.id)),
|
||||||
statuses: Immutable.List(action.results.statuses.map(item => item.id)),
|
statuses: ImmutableList(action.results.statuses.map(item => item.id)),
|
||||||
hashtags: Immutable.List(action.results.hashtags),
|
hashtags: ImmutableList(action.results.hashtags),
|
||||||
})).set('submitted', true);
|
})).set('submitted', true);
|
||||||
default:
|
default:
|
||||||
return state;
|
return state;
|
||||||
|
|
|
@ -1,39 +1,39 @@
|
||||||
import { SETTING_CHANGE } from '../actions/settings';
|
import { SETTING_CHANGE } from '../actions/settings';
|
||||||
import { COLUMN_ADD, COLUMN_REMOVE, COLUMN_MOVE } from '../actions/columns';
|
import { COLUMN_ADD, COLUMN_REMOVE, COLUMN_MOVE } from '../actions/columns';
|
||||||
import { STORE_HYDRATE } from '../actions/store';
|
import { STORE_HYDRATE } from '../actions/store';
|
||||||
import Immutable from 'immutable';
|
import { Map as ImmutableMap, fromJS } from 'immutable';
|
||||||
import uuid from '../uuid';
|
import uuid from '../uuid';
|
||||||
|
|
||||||
const initialState = Immutable.Map({
|
const initialState = ImmutableMap({
|
||||||
onboarded: false,
|
onboarded: false,
|
||||||
|
|
||||||
home: Immutable.Map({
|
home: ImmutableMap({
|
||||||
shows: Immutable.Map({
|
shows: ImmutableMap({
|
||||||
reblog: true,
|
reblog: true,
|
||||||
reply: true,
|
reply: true,
|
||||||
}),
|
}),
|
||||||
|
|
||||||
regex: Immutable.Map({
|
regex: ImmutableMap({
|
||||||
body: '',
|
body: '',
|
||||||
}),
|
}),
|
||||||
}),
|
}),
|
||||||
|
|
||||||
notifications: Immutable.Map({
|
notifications: ImmutableMap({
|
||||||
alerts: Immutable.Map({
|
alerts: ImmutableMap({
|
||||||
follow: true,
|
follow: true,
|
||||||
favourite: true,
|
favourite: true,
|
||||||
reblog: true,
|
reblog: true,
|
||||||
mention: true,
|
mention: true,
|
||||||
}),
|
}),
|
||||||
|
|
||||||
shows: Immutable.Map({
|
shows: ImmutableMap({
|
||||||
follow: true,
|
follow: true,
|
||||||
favourite: true,
|
favourite: true,
|
||||||
reblog: true,
|
reblog: true,
|
||||||
mention: true,
|
mention: true,
|
||||||
}),
|
}),
|
||||||
|
|
||||||
sounds: Immutable.Map({
|
sounds: ImmutableMap({
|
||||||
follow: true,
|
follow: true,
|
||||||
favourite: true,
|
favourite: true,
|
||||||
reblog: true,
|
reblog: true,
|
||||||
|
@ -41,20 +41,20 @@ const initialState = Immutable.Map({
|
||||||
}),
|
}),
|
||||||
}),
|
}),
|
||||||
|
|
||||||
community: Immutable.Map({
|
community: ImmutableMap({
|
||||||
regex: Immutable.Map({
|
regex: ImmutableMap({
|
||||||
body: '',
|
body: '',
|
||||||
}),
|
}),
|
||||||
}),
|
}),
|
||||||
|
|
||||||
public: Immutable.Map({
|
public: ImmutableMap({
|
||||||
regex: Immutable.Map({
|
regex: ImmutableMap({
|
||||||
body: '',
|
body: '',
|
||||||
}),
|
}),
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
|
|
||||||
const defaultColumns = Immutable.fromJS([
|
const defaultColumns = fromJS([
|
||||||
{ id: 'COMPOSE', uuid: uuid(), params: {} },
|
{ id: 'COMPOSE', uuid: uuid(), params: {} },
|
||||||
{ id: 'HOME', uuid: uuid(), params: {} },
|
{ id: 'HOME', uuid: uuid(), params: {} },
|
||||||
{ id: 'NOTIFICATIONS', uuid: uuid(), params: {} },
|
{ id: 'NOTIFICATIONS', uuid: uuid(), params: {} },
|
||||||
|
@ -82,7 +82,7 @@ export default function settings(state = initialState, action) {
|
||||||
case SETTING_CHANGE:
|
case SETTING_CHANGE:
|
||||||
return state.setIn(action.key, action.value);
|
return state.setIn(action.key, action.value);
|
||||||
case COLUMN_ADD:
|
case COLUMN_ADD:
|
||||||
return state.update('columns', list => list.push(Immutable.fromJS({ id: action.id, uuid: uuid(), params: action.params })));
|
return state.update('columns', list => list.push(fromJS({ id: action.id, uuid: uuid(), params: action.params })));
|
||||||
case COLUMN_REMOVE:
|
case COLUMN_REMOVE:
|
||||||
return state.update('columns', list => list.filterNot(item => item.get('uuid') === action.uuid));
|
return state.update('columns', list => list.filterNot(item => item.get('uuid') === action.uuid));
|
||||||
case COLUMN_MOVE:
|
case COLUMN_MOVE:
|
||||||
|
|
|
@ -2,13 +2,13 @@ import {
|
||||||
FAVOURITED_STATUSES_FETCH_SUCCESS,
|
FAVOURITED_STATUSES_FETCH_SUCCESS,
|
||||||
FAVOURITED_STATUSES_EXPAND_SUCCESS,
|
FAVOURITED_STATUSES_EXPAND_SUCCESS,
|
||||||
} from '../actions/favourites';
|
} from '../actions/favourites';
|
||||||
import Immutable from 'immutable';
|
import { Map as ImmutableMap, List as ImmutableList } from 'immutable';
|
||||||
|
|
||||||
const initialState = Immutable.Map({
|
const initialState = ImmutableMap({
|
||||||
favourites: Immutable.Map({
|
favourites: ImmutableMap({
|
||||||
next: null,
|
next: null,
|
||||||
loaded: false,
|
loaded: false,
|
||||||
items: Immutable.List(),
|
items: ImmutableList(),
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@ const normalizeList = (state, listType, statuses, next) => {
|
||||||
return state.update(listType, listMap => listMap.withMutations(map => {
|
return state.update(listType, listMap => listMap.withMutations(map => {
|
||||||
map.set('next', next);
|
map.set('next', next);
|
||||||
map.set('loaded', true);
|
map.set('loaded', true);
|
||||||
map.set('items', Immutable.List(statuses.map(item => item.id)));
|
map.set('items', ImmutableList(statuses.map(item => item.id)));
|
||||||
}));
|
}));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,7 @@ import {
|
||||||
FAVOURITED_STATUSES_EXPAND_SUCCESS,
|
FAVOURITED_STATUSES_EXPAND_SUCCESS,
|
||||||
} from '../actions/favourites';
|
} from '../actions/favourites';
|
||||||
import { SEARCH_FETCH_SUCCESS } from '../actions/search';
|
import { SEARCH_FETCH_SUCCESS } from '../actions/search';
|
||||||
import Immutable from 'immutable';
|
import { Map as ImmutableMap, fromJS } from 'immutable';
|
||||||
|
|
||||||
const normalizeStatus = (state, status) => {
|
const normalizeStatus = (state, status) => {
|
||||||
if (!status) {
|
if (!status) {
|
||||||
|
@ -51,7 +51,7 @@ const normalizeStatus = (state, status) => {
|
||||||
const searchContent = [status.spoiler_text, status.content].join(' ').replace(/<br \/>/g, '\n').replace(/<\/p><p>/g, '\n\n');
|
const searchContent = [status.spoiler_text, status.content].join(' ').replace(/<br \/>/g, '\n').replace(/<\/p><p>/g, '\n\n');
|
||||||
normalStatus.search_index = new DOMParser().parseFromString(searchContent, 'text/html').documentElement.textContent;
|
normalStatus.search_index = new DOMParser().parseFromString(searchContent, 'text/html').documentElement.textContent;
|
||||||
|
|
||||||
return state.update(status.id, Immutable.Map(), map => map.mergeDeep(Immutable.fromJS(normalStatus)));
|
return state.update(status.id, ImmutableMap(), map => map.mergeDeep(fromJS(normalStatus)));
|
||||||
};
|
};
|
||||||
|
|
||||||
const normalizeStatuses = (state, statuses) => {
|
const normalizeStatuses = (state, statuses) => {
|
||||||
|
@ -82,7 +82,7 @@ const filterStatuses = (state, relationship) => {
|
||||||
return state;
|
return state;
|
||||||
};
|
};
|
||||||
|
|
||||||
const initialState = Immutable.Map();
|
const initialState = ImmutableMap();
|
||||||
|
|
||||||
export default function statuses(state = initialState, action) {
|
export default function statuses(state = initialState, action) {
|
||||||
switch(action.type) {
|
switch(action.type) {
|
||||||
|
|
|
@ -15,25 +15,25 @@ import {
|
||||||
ACCOUNT_BLOCK_SUCCESS,
|
ACCOUNT_BLOCK_SUCCESS,
|
||||||
ACCOUNT_MUTE_SUCCESS,
|
ACCOUNT_MUTE_SUCCESS,
|
||||||
} from '../actions/accounts';
|
} 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,
|
unread: 0,
|
||||||
online: false,
|
online: false,
|
||||||
top: true,
|
top: true,
|
||||||
loaded: false,
|
loaded: false,
|
||||||
isLoading: false,
|
isLoading: false,
|
||||||
next: false,
|
next: false,
|
||||||
items: Immutable.List(),
|
items: ImmutableList(),
|
||||||
});
|
});
|
||||||
|
|
||||||
const normalizeTimeline = (state, timeline, statuses, next) => {
|
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 wasLoaded = state.getIn([timeline, 'loaded']);
|
||||||
const hadNext = state.getIn([timeline, 'next']);
|
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 => {
|
return state.update(timeline, initialTimeline, map => map.withMutations(mMap => {
|
||||||
mMap.set('loaded', true);
|
mMap.set('loaded', true);
|
||||||
|
@ -44,8 +44,8 @@ const normalizeTimeline = (state, timeline, statuses, next) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const appendNormalizedTimeline = (state, timeline, statuses, next) => {
|
const appendNormalizedTimeline = (state, timeline, statuses, next) => {
|
||||||
const ids = Immutable.List(statuses.map(status => status.get('id')));
|
const ids = ImmutableList(statuses.map(status => status.get('id')));
|
||||||
const oldIds = state.getIn([timeline, 'items'], Immutable.List());
|
const oldIds = state.getIn([timeline, 'items'], ImmutableList());
|
||||||
|
|
||||||
return state.update(timeline, initialTimeline, map => map.withMutations(mMap => {
|
return state.update(timeline, initialTimeline, map => map.withMutations(mMap => {
|
||||||
mMap.set('isLoading', false);
|
mMap.set('isLoading', false);
|
||||||
|
@ -56,7 +56,7 @@ const appendNormalizedTimeline = (state, timeline, statuses, next) => {
|
||||||
|
|
||||||
const updateTimeline = (state, timeline, status, references) => {
|
const updateTimeline = (state, timeline, status, references) => {
|
||||||
const top = state.getIn([timeline, 'top']);
|
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 includesId = ids.includes(status.get('id'));
|
||||||
const unread = state.getIn([timeline, 'unread'], 0);
|
const unread = state.getIn([timeline, 'unread'], 0);
|
||||||
|
|
||||||
|
@ -124,11 +124,11 @@ export default function timelines(state = initialState, action) {
|
||||||
case TIMELINE_EXPAND_FAIL:
|
case TIMELINE_EXPAND_FAIL:
|
||||||
return state.update(action.timeline, initialTimeline, map => map.set('isLoading', false));
|
return state.update(action.timeline, initialTimeline, map => map.set('isLoading', false));
|
||||||
case TIMELINE_REFRESH_SUCCESS:
|
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:
|
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:
|
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:
|
case TIMELINE_DELETE:
|
||||||
return deleteStatus(state, action.id, action.accountId, action.references, action.reblogOf);
|
return deleteStatus(state, action.id, action.accountId, action.references, action.reblogOf);
|
||||||
case ACCOUNT_BLOCK_SUCCESS:
|
case ACCOUNT_BLOCK_SUCCESS:
|
||||||
|
|
|
@ -20,22 +20,22 @@ import {
|
||||||
MUTES_FETCH_SUCCESS,
|
MUTES_FETCH_SUCCESS,
|
||||||
MUTES_EXPAND_SUCCESS,
|
MUTES_EXPAND_SUCCESS,
|
||||||
} from '../actions/mutes';
|
} from '../actions/mutes';
|
||||||
import Immutable from 'immutable';
|
import { Map as ImmutableMap, List as ImmutableList } from 'immutable';
|
||||||
|
|
||||||
const initialState = Immutable.Map({
|
const initialState = ImmutableMap({
|
||||||
followers: Immutable.Map(),
|
followers: ImmutableMap(),
|
||||||
following: Immutable.Map(),
|
following: ImmutableMap(),
|
||||||
reblogged_by: Immutable.Map(),
|
reblogged_by: ImmutableMap(),
|
||||||
favourited_by: Immutable.Map(),
|
favourited_by: ImmutableMap(),
|
||||||
follow_requests: Immutable.Map(),
|
follow_requests: ImmutableMap(),
|
||||||
blocks: Immutable.Map(),
|
blocks: ImmutableMap(),
|
||||||
mutes: Immutable.Map(),
|
mutes: ImmutableMap(),
|
||||||
});
|
});
|
||||||
|
|
||||||
const normalizeList = (state, type, id, accounts, next) => {
|
const normalizeList = (state, type, id, accounts, next) => {
|
||||||
return state.setIn([type, id], Immutable.Map({
|
return state.setIn([type, id], ImmutableMap({
|
||||||
next,
|
next,
|
||||||
items: Immutable.List(accounts.map(item => item.id)),
|
items: ImmutableList(accounts.map(item => item.id)),
|
||||||
}));
|
}));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -56,22 +56,22 @@ export default function userLists(state = initialState, action) {
|
||||||
case FOLLOWING_EXPAND_SUCCESS:
|
case FOLLOWING_EXPAND_SUCCESS:
|
||||||
return appendToList(state, 'following', action.id, action.accounts, action.next);
|
return appendToList(state, 'following', action.id, action.accounts, action.next);
|
||||||
case REBLOGS_FETCH_SUCCESS:
|
case REBLOGS_FETCH_SUCCESS:
|
||||||
return state.setIn(['reblogged_by', action.id], Immutable.List(action.accounts.map(item => item.id)));
|
return state.setIn(['reblogged_by', action.id], ImmutableList(action.accounts.map(item => item.id)));
|
||||||
case FAVOURITES_FETCH_SUCCESS:
|
case FAVOURITES_FETCH_SUCCESS:
|
||||||
return state.setIn(['favourited_by', action.id], Immutable.List(action.accounts.map(item => item.id)));
|
return state.setIn(['favourited_by', action.id], ImmutableList(action.accounts.map(item => item.id)));
|
||||||
case FOLLOW_REQUESTS_FETCH_SUCCESS:
|
case FOLLOW_REQUESTS_FETCH_SUCCESS:
|
||||||
return state.setIn(['follow_requests', 'items'], Immutable.List(action.accounts.map(item => item.id))).setIn(['follow_requests', 'next'], action.next);
|
return state.setIn(['follow_requests', 'items'], ImmutableList(action.accounts.map(item => item.id))).setIn(['follow_requests', 'next'], action.next);
|
||||||
case FOLLOW_REQUESTS_EXPAND_SUCCESS:
|
case FOLLOW_REQUESTS_EXPAND_SUCCESS:
|
||||||
return state.updateIn(['follow_requests', 'items'], list => list.concat(action.accounts.map(item => item.id))).setIn(['follow_requests', 'next'], action.next);
|
return state.updateIn(['follow_requests', 'items'], list => list.concat(action.accounts.map(item => item.id))).setIn(['follow_requests', 'next'], action.next);
|
||||||
case FOLLOW_REQUEST_AUTHORIZE_SUCCESS:
|
case FOLLOW_REQUEST_AUTHORIZE_SUCCESS:
|
||||||
case FOLLOW_REQUEST_REJECT_SUCCESS:
|
case FOLLOW_REQUEST_REJECT_SUCCESS:
|
||||||
return state.updateIn(['follow_requests', 'items'], list => list.filterNot(item => item === action.id));
|
return state.updateIn(['follow_requests', 'items'], list => list.filterNot(item => item === action.id));
|
||||||
case BLOCKS_FETCH_SUCCESS:
|
case BLOCKS_FETCH_SUCCESS:
|
||||||
return state.setIn(['blocks', 'items'], Immutable.List(action.accounts.map(item => item.id))).setIn(['blocks', 'next'], action.next);
|
return state.setIn(['blocks', 'items'], ImmutableList(action.accounts.map(item => item.id))).setIn(['blocks', 'next'], action.next);
|
||||||
case BLOCKS_EXPAND_SUCCESS:
|
case BLOCKS_EXPAND_SUCCESS:
|
||||||
return state.updateIn(['blocks', 'items'], list => list.concat(action.accounts.map(item => item.id))).setIn(['blocks', 'next'], action.next);
|
return state.updateIn(['blocks', 'items'], list => list.concat(action.accounts.map(item => item.id))).setIn(['blocks', 'next'], action.next);
|
||||||
case MUTES_FETCH_SUCCESS:
|
case MUTES_FETCH_SUCCESS:
|
||||||
return state.setIn(['mutes', 'items'], Immutable.List(action.accounts.map(item => item.id))).setIn(['mutes', 'next'], action.next);
|
return state.setIn(['mutes', 'items'], ImmutableList(action.accounts.map(item => item.id))).setIn(['mutes', 'next'], action.next);
|
||||||
case MUTES_EXPAND_SUCCESS:
|
case MUTES_EXPAND_SUCCESS:
|
||||||
return state.updateIn(['mutes', 'items'], list => list.concat(action.accounts.map(item => item.id))).setIn(['mutes', 'next'], action.next);
|
return state.updateIn(['mutes', 'items'], list => list.concat(action.accounts.map(item => item.id))).setIn(['mutes', 'next'], action.next);
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { createSelector } from 'reselect';
|
import { createSelector } from 'reselect';
|
||||||
import Immutable from 'immutable';
|
import { List as ImmutableList } from 'immutable';
|
||||||
|
|
||||||
const getAccountBase = (state, id) => state.getIn(['accounts', id], null);
|
const getAccountBase = (state, id) => state.getIn(['accounts', id], null);
|
||||||
const getAccountCounters = (state, id) => state.getIn(['accounts_counters', id], null);
|
const getAccountCounters = (state, id) => state.getIn(['accounts_counters', id], null);
|
||||||
|
@ -73,10 +73,10 @@ export const makeGetNotification = () => {
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getAccountGallery = createSelector([
|
export const getAccountGallery = createSelector([
|
||||||
(state, id) => state.getIn(['timelines', `account:${id}:media`, 'items'], Immutable.List()),
|
(state, id) => state.getIn(['timelines', `account:${id}:media`, 'items'], ImmutableList()),
|
||||||
state => state.get('statuses'),
|
state => state.get('statuses'),
|
||||||
], (statusIds, statuses) => {
|
], (statusIds, statuses) => {
|
||||||
let medias = Immutable.List();
|
let medias = ImmutableList();
|
||||||
|
|
||||||
statusIds.forEach(statusId => {
|
statusIds.forEach(statusId => {
|
||||||
const status = statuses.get(statusId);
|
const status = statuses.get(statusId);
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
import { expect } from 'chai';
|
import { expect } from 'chai';
|
||||||
import { render } from 'enzyme';
|
import { render } from 'enzyme';
|
||||||
import Immutable from 'immutable';
|
import { fromJS } from 'immutable';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import DisplayName from '../../../app/javascript/mastodon/components/display_name';
|
import DisplayName from '../../../app/javascript/mastodon/components/display_name';
|
||||||
|
|
||||||
describe('<DisplayName />', () => {
|
describe('<DisplayName />', () => {
|
||||||
it('renders display name + account name', () => {
|
it('renders display name + account name', () => {
|
||||||
const account = Immutable.fromJS({
|
const account = fromJS({
|
||||||
username: 'bar',
|
username: 'bar',
|
||||||
acct: 'bar@baz',
|
acct: 'bar@baz',
|
||||||
display_name: 'Foo',
|
display_name: 'Foo',
|
||||||
|
@ -16,7 +16,7 @@ describe('<DisplayName />', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('renders the username + account name if display name is empty', () => {
|
it('renders the username + account name if display name is empty', () => {
|
||||||
const account = Immutable.fromJS({
|
const account = fromJS({
|
||||||
username: 'bar',
|
username: 'bar',
|
||||||
acct: 'bar@baz',
|
acct: 'bar@baz',
|
||||||
display_name: '',
|
display_name: '',
|
||||||
|
|
Loading…
Reference in New Issue