1
0
mirror of https://github.com/mastodon/mastodon synced 2024-11-23 14:46:18 +09:00

Update immutable imports for v5 (#33037)

This commit is contained in:
Nick Schonning 2024-11-22 17:23:02 -05:00 committed by GitHub
parent 21a8612aab
commit 27e79da6b9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 28 additions and 24 deletions

View File

@ -8,7 +8,7 @@ import { FormattedMessage } from 'react-intl';
import classNames from 'classnames';
import Immutable from 'immutable';
import { is } from 'immutable';
import ImmutablePropTypes from 'react-immutable-proptypes';
import DescriptionIcon from '@/material-icons/400-24px/description-fill.svg?react';
@ -73,7 +73,7 @@ export default class Card extends PureComponent {
};
UNSAFE_componentWillReceiveProps (nextProps) {
if (!Immutable.is(this.props.card, nextProps.card)) {
if (!is(this.props.card, nextProps.card)) {
this.setState({ embedded: false, previewLoaded: false });
}

View File

@ -7,7 +7,7 @@ import { Helmet } from 'react-helmet';
import { withRouter } from 'react-router-dom';
import { createSelector } from '@reduxjs/toolkit';
import Immutable from 'immutable';
import { List as ImmutableList } from 'immutable';
import ImmutablePropTypes from 'react-immutable-proptypes';
import ImmutablePureComponent from 'react-immutable-pure-component';
import { connect } from 'react-redux';
@ -87,7 +87,7 @@ const makeMapStateToProps = () => {
(_, { id }) => id,
state => state.getIn(['contexts', 'inReplyTos']),
], (statusId, inReplyTos) => {
let ancestorsIds = Immutable.List();
let ancestorsIds = ImmutableList();
ancestorsIds = ancestorsIds.withMutations(mutable => {
let id = statusId;
@ -134,14 +134,14 @@ const makeMapStateToProps = () => {
});
}
return Immutable.List(descendantsIds);
return ImmutableList(descendantsIds);
});
const mapStateToProps = (state, props) => {
const status = getStatus(state, { id: props.params.statusId });
let ancestorsIds = Immutable.List();
let descendantsIds = Immutable.List();
let ancestorsIds = ImmutableList();
let descendantsIds = ImmutableList();
if (status) {
ancestorsIds = getAncestorsIds(state, { id: status.get('in_reply_to_id') });

View File

@ -23,7 +23,7 @@ const getAccountLanguages = createSelector([
(state, accountId) => state.getIn(['timelines', `account:${accountId}`, 'items'], ImmutableList()),
state => state.get('statuses'),
], (statusIds, statuses) =>
new ImmutableSet(statusIds.map(statusId => statuses.get(statusId)).filter(status => !status.get('reblog')).map(status => status.get('language'))));
ImmutableSet(statusIds.map(statusId => statuses.get(statusId)).filter(status => !status.get('reblog')).map(status => status.get('language'))));
const mapStateToProps = (state, { accountId }) => ({
acct: state.getIn(['accounts', accountId, 'acct']),

View File

@ -1,5 +1,5 @@
import type { RecordOf } from 'immutable';
import { List, Record as ImmutableRecord } from 'immutable';
import { List as ImmutableList, Record as ImmutableRecord } from 'immutable';
import escapeTextContentForBrowser from 'escape-html';
@ -48,9 +48,9 @@ export interface AccountShape
extends Required<
Omit<ApiAccountJSON, 'emojis' | 'fields' | 'roles' | 'moved'>
> {
emojis: List<CustomEmoji>;
fields: List<AccountField>;
roles: List<AccountRole>;
emojis: ImmutableList<CustomEmoji>;
fields: ImmutableList<AccountField>;
roles: ImmutableList<AccountRole>;
display_name_html: string;
note_emojified: string;
note_plain: string | null;
@ -70,8 +70,8 @@ export const accountDefaultValues: AccountShape = {
indexable: false,
display_name: '',
display_name_html: '',
emojis: List<CustomEmoji>(),
fields: List<AccountField>(),
emojis: ImmutableList<CustomEmoji>(),
fields: ImmutableList<AccountField>(),
group: false,
header: '',
header_static: '',
@ -82,7 +82,7 @@ export const accountDefaultValues: AccountShape = {
note: '',
note_emojified: '',
note_plain: 'string',
roles: List<AccountRole>(),
roles: ImmutableList<AccountRole>(),
uri: '',
url: '',
username: '',
@ -139,11 +139,15 @@ export function createAccountFromServerJSON(serverJSON: ApiAccountJSON) {
return AccountFactory({
...accountJSON,
moved: moved?.id,
fields: List(
fields: ImmutableList(
serverJSON.fields.map((field) => createAccountField(field, emojiMap)),
),
emojis: List(serverJSON.emojis.map((emoji) => CustomEmojiFactory(emoji))),
roles: List(serverJSON.roles?.map((role) => AccountRoleFactory(role))),
emojis: ImmutableList(
serverJSON.emojis.map((emoji) => CustomEmojiFactory(emoji)),
),
roles: ImmutableList(
serverJSON.roles?.map((role) => AccountRoleFactory(role)),
),
display_name_html: emojify(
escapeTextContentForBrowser(displayName),
emojiMap,

View File

@ -1,11 +1,11 @@
import Immutable from 'immutable';
import { Map as ImmutableMap } from 'immutable';
import { SET_BROWSER_SUPPORT, SET_SUBSCRIPTION, CLEAR_SUBSCRIPTION, SET_ALERTS } from '../actions/push_notifications';
import { STORE_HYDRATE } from '../actions/store';
const initialState = Immutable.Map({
const initialState = ImmutableMap({
subscription: null,
alerts: new Immutable.Map({
alerts: ImmutableMap({
follow: false,
follow_request: false,
favourite: false,
@ -24,7 +24,7 @@ export default function push_subscriptions(state = initialState, action) {
if (push_subscription) {
return state
.set('subscription', new Immutable.Map({
.set('subscription', ImmutableMap({
id: push_subscription.get('id'),
endpoint: push_subscription.get('endpoint'),
}))
@ -36,11 +36,11 @@ export default function push_subscriptions(state = initialState, action) {
}
case SET_SUBSCRIPTION:
return state
.set('subscription', new Immutable.Map({
.set('subscription', ImmutableMap({
id: action.subscription.id,
endpoint: action.subscription.endpoint,
}))
.set('alerts', new Immutable.Map(action.subscription.alerts))
.set('alerts', ImmutableMap(action.subscription.alerts))
.set('isSubscribed', true);
case SET_BROWSER_SUPPORT:
return state.set('browserSupport', action.value);