From 33aaffa22dbee15b36795251afdaa7f50d8efcc3 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Sun, 12 Sep 2021 11:25:44 -0500 Subject: [PATCH] Use immutable.js consistently --- app/soapbox/features/status/components/card.js | 6 +++--- app/soapbox/features/status/index.js | 12 ++++++------ app/soapbox/reducers/dropdown_menu.js | 4 ++-- app/soapbox/reducers/mutes.js | 6 +++--- app/soapbox/reducers/push_notifications.js | 10 +++++----- 5 files changed, 19 insertions(+), 19 deletions(-) diff --git a/app/soapbox/features/status/components/card.js b/app/soapbox/features/status/components/card.js index a0506a694..d2e349bca 100644 --- a/app/soapbox/features/status/components/card.js +++ b/app/soapbox/features/status/components/card.js @@ -1,6 +1,6 @@ import React from 'react'; import PropTypes from 'prop-types'; -import Immutable from 'immutable'; +import { is, fromJS } from 'immutable'; import ImmutablePropTypes from 'react-immutable-proptypes'; import punycode from 'punycode'; import classnames from 'classnames'; @@ -77,7 +77,7 @@ export default class Card extends React.PureComponent { }; componentDidUpdate(prevProps) { - if (!Immutable.is(prevProps.card, this.props.card)) { + if (!is(prevProps.card, this.props.card)) { this.setState({ embedded: false }); } } @@ -86,7 +86,7 @@ export default class Card extends React.PureComponent { const { card, onOpenMedia } = this.props; onOpenMedia( - Immutable.fromJS([ + fromJS([ { type: 'image', url: card.get('embed_url'), diff --git a/app/soapbox/features/status/index.js b/app/soapbox/features/status/index.js index 3f9ad0f0c..c6262057e 100644 --- a/app/soapbox/features/status/index.js +++ b/app/soapbox/features/status/index.js @@ -1,4 +1,4 @@ -import Immutable from 'immutable'; +import { OrderedSet as ImmutableOrderedSet } from 'immutable'; import React from 'react'; import { connect } from 'react-redux'; import PropTypes from 'prop-types'; @@ -71,11 +71,11 @@ const makeMapStateToProps = () => { (_, { id }) => id, state => state.getIn(['contexts', 'inReplyTos']), ], (statusId, inReplyTos) => { - let ancestorsIds = Immutable.OrderedSet(); + let ancestorsIds = ImmutableOrderedSet(); let id = statusId; while (id) { - ancestorsIds = Immutable.OrderedSet([id]).union(ancestorsIds); + ancestorsIds = ImmutableOrderedSet([id]).union(ancestorsIds); id = inReplyTos.get(id); } @@ -86,7 +86,7 @@ const makeMapStateToProps = () => { (_, { id }) => id, state => state.getIn(['contexts', 'replies']), ], (statusId, contextReplies) => { - let descendantsIds = Immutable.OrderedSet(); + let descendantsIds = ImmutableOrderedSet(); const ids = [statusId]; while (ids.length > 0) { @@ -109,8 +109,8 @@ const makeMapStateToProps = () => { const mapStateToProps = (state, props) => { const status = getStatus(state, { id: props.params.statusId }); - let ancestorsIds = Immutable.OrderedSet(); - let descendantsIds = Immutable.OrderedSet(); + let ancestorsIds = ImmutableOrderedSet(); + let descendantsIds = ImmutableOrderedSet(); if (status) { ancestorsIds = getAncestorsIds(state, { id: state.getIn(['contexts', 'inReplyTos', status.get('id')]) }); diff --git a/app/soapbox/reducers/dropdown_menu.js b/app/soapbox/reducers/dropdown_menu.js index 36fd4f132..4cceee9f5 100644 --- a/app/soapbox/reducers/dropdown_menu.js +++ b/app/soapbox/reducers/dropdown_menu.js @@ -1,10 +1,10 @@ -import Immutable from 'immutable'; +import { Map as ImmutableMap } from 'immutable'; import { DROPDOWN_MENU_OPEN, DROPDOWN_MENU_CLOSE, } 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) { switch (action.type) { diff --git a/app/soapbox/reducers/mutes.js b/app/soapbox/reducers/mutes.js index a96232dbd..56fd39fb3 100644 --- a/app/soapbox/reducers/mutes.js +++ b/app/soapbox/reducers/mutes.js @@ -1,12 +1,12 @@ -import Immutable from 'immutable'; +import { Map as ImmutableMap } from 'immutable'; import { MUTES_INIT_MODAL, MUTES_TOGGLE_HIDE_NOTIFICATIONS, } from '../actions/mutes'; -const initialState = Immutable.Map({ - new: Immutable.Map({ +const initialState = ImmutableMap({ + new: ImmutableMap({ isSubmitting: false, account: null, notifications: true, diff --git a/app/soapbox/reducers/push_notifications.js b/app/soapbox/reducers/push_notifications.js index d68845908..e72952934 100644 --- a/app/soapbox/reducers/push_notifications.js +++ b/app/soapbox/reducers/push_notifications.js @@ -1,9 +1,9 @@ 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, - alerts: new Immutable.Map({ + alerts: new ImmutableMap({ follow: false, follow_request: false, favourite: false, @@ -19,11 +19,11 @@ export default function push_subscriptions(state = initialState, action) { switch(action.type) { case SET_SUBSCRIPTION: return state - .set('subscription', new Immutable.Map({ + .set('subscription', new ImmutableMap({ id: action.subscription.id, endpoint: action.subscription.endpoint, })) - .set('alerts', new Immutable.Map(action.subscription.alerts)) + .set('alerts', new ImmutableMap(action.subscription.alerts)) .set('isSubscribed', true); case SET_BROWSER_SUPPORT: return state.set('browserSupport', action.value);