Use immutable.js consistently
This commit is contained in:
parent
5921fa9b2d
commit
33aaffa22d
|
@ -1,6 +1,6 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import Immutable from 'immutable';
|
import { is, fromJS } from 'immutable';
|
||||||
import ImmutablePropTypes from 'react-immutable-proptypes';
|
import ImmutablePropTypes from 'react-immutable-proptypes';
|
||||||
import punycode from 'punycode';
|
import punycode from 'punycode';
|
||||||
import classnames from 'classnames';
|
import classnames from 'classnames';
|
||||||
|
@ -77,7 +77,7 @@ export default class Card extends React.PureComponent {
|
||||||
};
|
};
|
||||||
|
|
||||||
componentDidUpdate(prevProps) {
|
componentDidUpdate(prevProps) {
|
||||||
if (!Immutable.is(prevProps.card, this.props.card)) {
|
if (!is(prevProps.card, this.props.card)) {
|
||||||
this.setState({ embedded: false });
|
this.setState({ embedded: false });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -86,7 +86,7 @@ export default class Card extends React.PureComponent {
|
||||||
const { card, onOpenMedia } = this.props;
|
const { card, onOpenMedia } = this.props;
|
||||||
|
|
||||||
onOpenMedia(
|
onOpenMedia(
|
||||||
Immutable.fromJS([
|
fromJS([
|
||||||
{
|
{
|
||||||
type: 'image',
|
type: 'image',
|
||||||
url: card.get('embed_url'),
|
url: card.get('embed_url'),
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import Immutable from 'immutable';
|
import { OrderedSet as ImmutableOrderedSet } from 'immutable';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
|
@ -71,11 +71,11 @@ const makeMapStateToProps = () => {
|
||||||
(_, { id }) => id,
|
(_, { id }) => id,
|
||||||
state => state.getIn(['contexts', 'inReplyTos']),
|
state => state.getIn(['contexts', 'inReplyTos']),
|
||||||
], (statusId, inReplyTos) => {
|
], (statusId, inReplyTos) => {
|
||||||
let ancestorsIds = Immutable.OrderedSet();
|
let ancestorsIds = ImmutableOrderedSet();
|
||||||
let id = statusId;
|
let id = statusId;
|
||||||
|
|
||||||
while (id) {
|
while (id) {
|
||||||
ancestorsIds = Immutable.OrderedSet([id]).union(ancestorsIds);
|
ancestorsIds = ImmutableOrderedSet([id]).union(ancestorsIds);
|
||||||
id = inReplyTos.get(id);
|
id = inReplyTos.get(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -86,7 +86,7 @@ const makeMapStateToProps = () => {
|
||||||
(_, { id }) => id,
|
(_, { id }) => id,
|
||||||
state => state.getIn(['contexts', 'replies']),
|
state => state.getIn(['contexts', 'replies']),
|
||||||
], (statusId, contextReplies) => {
|
], (statusId, contextReplies) => {
|
||||||
let descendantsIds = Immutable.OrderedSet();
|
let descendantsIds = ImmutableOrderedSet();
|
||||||
const ids = [statusId];
|
const ids = [statusId];
|
||||||
|
|
||||||
while (ids.length > 0) {
|
while (ids.length > 0) {
|
||||||
|
@ -109,8 +109,8 @@ const makeMapStateToProps = () => {
|
||||||
|
|
||||||
const mapStateToProps = (state, props) => {
|
const mapStateToProps = (state, props) => {
|
||||||
const status = getStatus(state, { id: props.params.statusId });
|
const status = getStatus(state, { id: props.params.statusId });
|
||||||
let ancestorsIds = Immutable.OrderedSet();
|
let ancestorsIds = ImmutableOrderedSet();
|
||||||
let descendantsIds = Immutable.OrderedSet();
|
let descendantsIds = ImmutableOrderedSet();
|
||||||
|
|
||||||
if (status) {
|
if (status) {
|
||||||
ancestorsIds = getAncestorsIds(state, { id: state.getIn(['contexts', 'inReplyTos', status.get('id')]) });
|
ancestorsIds = getAncestorsIds(state, { id: state.getIn(['contexts', 'inReplyTos', status.get('id')]) });
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
import Immutable from 'immutable';
|
import { Map as ImmutableMap } from 'immutable';
|
||||||
import {
|
import {
|
||||||
DROPDOWN_MENU_OPEN,
|
DROPDOWN_MENU_OPEN,
|
||||||
DROPDOWN_MENU_CLOSE,
|
DROPDOWN_MENU_CLOSE,
|
||||||
} from '../actions/dropdown_menu';
|
} from '../actions/dropdown_menu';
|
||||||
|
|
||||||
const initialState = Immutable.Map({ openId: null, placement: null, keyboard: false });
|
const initialState = ImmutableMap({ openId: null, placement: null, keyboard: false });
|
||||||
|
|
||||||
export default function dropdownMenu(state = initialState, action) {
|
export default function dropdownMenu(state = initialState, action) {
|
||||||
switch (action.type) {
|
switch (action.type) {
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
import Immutable from 'immutable';
|
import { Map as ImmutableMap } from 'immutable';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
MUTES_INIT_MODAL,
|
MUTES_INIT_MODAL,
|
||||||
MUTES_TOGGLE_HIDE_NOTIFICATIONS,
|
MUTES_TOGGLE_HIDE_NOTIFICATIONS,
|
||||||
} from '../actions/mutes';
|
} from '../actions/mutes';
|
||||||
|
|
||||||
const initialState = Immutable.Map({
|
const initialState = ImmutableMap({
|
||||||
new: Immutable.Map({
|
new: ImmutableMap({
|
||||||
isSubmitting: false,
|
isSubmitting: false,
|
||||||
account: null,
|
account: null,
|
||||||
notifications: true,
|
notifications: true,
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
import { SET_BROWSER_SUPPORT, SET_SUBSCRIPTION, CLEAR_SUBSCRIPTION, SET_ALERTS } from '../actions/push_notifications';
|
import { SET_BROWSER_SUPPORT, SET_SUBSCRIPTION, CLEAR_SUBSCRIPTION, SET_ALERTS } from '../actions/push_notifications';
|
||||||
import Immutable from 'immutable';
|
import { Map as ImmutableMap } from 'immutable';
|
||||||
|
|
||||||
const initialState = Immutable.Map({
|
const initialState = ImmutableMap({
|
||||||
subscription: null,
|
subscription: null,
|
||||||
alerts: new Immutable.Map({
|
alerts: new ImmutableMap({
|
||||||
follow: false,
|
follow: false,
|
||||||
follow_request: false,
|
follow_request: false,
|
||||||
favourite: false,
|
favourite: false,
|
||||||
|
@ -19,11 +19,11 @@ export default function push_subscriptions(state = initialState, action) {
|
||||||
switch(action.type) {
|
switch(action.type) {
|
||||||
case SET_SUBSCRIPTION:
|
case SET_SUBSCRIPTION:
|
||||||
return state
|
return state
|
||||||
.set('subscription', new Immutable.Map({
|
.set('subscription', new ImmutableMap({
|
||||||
id: action.subscription.id,
|
id: action.subscription.id,
|
||||||
endpoint: action.subscription.endpoint,
|
endpoint: action.subscription.endpoint,
|
||||||
}))
|
}))
|
||||||
.set('alerts', new Immutable.Map(action.subscription.alerts))
|
.set('alerts', new ImmutableMap(action.subscription.alerts))
|
||||||
.set('isSubscribed', true);
|
.set('isSubscribed', true);
|
||||||
case SET_BROWSER_SUPPORT:
|
case SET_BROWSER_SUPPORT:
|
||||||
return state.set('browserSupport', action.value);
|
return state.set('browserSupport', action.value);
|
||||||
|
|
Loading…
Reference in New Issue