mirror of
https://github.com/mastodon/mastodon.git
synced 2024-12-25 10:17:47 +00:00
Update immutable imports for v5 (#33037)
This commit is contained in:
parent
21a8612aab
commit
27e79da6b9
|
@ -8,7 +8,7 @@ import { FormattedMessage } from 'react-intl';
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
|
|
||||||
|
|
||||||
import Immutable from 'immutable';
|
import { is } from 'immutable';
|
||||||
import ImmutablePropTypes from 'react-immutable-proptypes';
|
import ImmutablePropTypes from 'react-immutable-proptypes';
|
||||||
|
|
||||||
import DescriptionIcon from '@/material-icons/400-24px/description-fill.svg?react';
|
import DescriptionIcon from '@/material-icons/400-24px/description-fill.svg?react';
|
||||||
|
@ -73,7 +73,7 @@ export default class Card extends PureComponent {
|
||||||
};
|
};
|
||||||
|
|
||||||
UNSAFE_componentWillReceiveProps (nextProps) {
|
UNSAFE_componentWillReceiveProps (nextProps) {
|
||||||
if (!Immutable.is(this.props.card, nextProps.card)) {
|
if (!is(this.props.card, nextProps.card)) {
|
||||||
this.setState({ embedded: false, previewLoaded: false });
|
this.setState({ embedded: false, previewLoaded: false });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@ import { Helmet } from 'react-helmet';
|
||||||
import { withRouter } from 'react-router-dom';
|
import { withRouter } from 'react-router-dom';
|
||||||
|
|
||||||
import { createSelector } from '@reduxjs/toolkit';
|
import { createSelector } from '@reduxjs/toolkit';
|
||||||
import Immutable from 'immutable';
|
import { List as ImmutableList } from 'immutable';
|
||||||
import ImmutablePropTypes from 'react-immutable-proptypes';
|
import ImmutablePropTypes from 'react-immutable-proptypes';
|
||||||
import ImmutablePureComponent from 'react-immutable-pure-component';
|
import ImmutablePureComponent from 'react-immutable-pure-component';
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
|
@ -87,7 +87,7 @@ const makeMapStateToProps = () => {
|
||||||
(_, { id }) => id,
|
(_, { id }) => id,
|
||||||
state => state.getIn(['contexts', 'inReplyTos']),
|
state => state.getIn(['contexts', 'inReplyTos']),
|
||||||
], (statusId, inReplyTos) => {
|
], (statusId, inReplyTos) => {
|
||||||
let ancestorsIds = Immutable.List();
|
let ancestorsIds = ImmutableList();
|
||||||
ancestorsIds = ancestorsIds.withMutations(mutable => {
|
ancestorsIds = ancestorsIds.withMutations(mutable => {
|
||||||
let id = statusId;
|
let id = statusId;
|
||||||
|
|
||||||
|
@ -134,14 +134,14 @@ const makeMapStateToProps = () => {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
return Immutable.List(descendantsIds);
|
return ImmutableList(descendantsIds);
|
||||||
});
|
});
|
||||||
|
|
||||||
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.List();
|
let ancestorsIds = ImmutableList();
|
||||||
let descendantsIds = Immutable.List();
|
let descendantsIds = ImmutableList();
|
||||||
|
|
||||||
if (status) {
|
if (status) {
|
||||||
ancestorsIds = getAncestorsIds(state, { id: status.get('in_reply_to_id') });
|
ancestorsIds = getAncestorsIds(state, { id: status.get('in_reply_to_id') });
|
||||||
|
|
|
@ -23,7 +23,7 @@ const getAccountLanguages = createSelector([
|
||||||
(state, accountId) => state.getIn(['timelines', `account:${accountId}`, 'items'], ImmutableList()),
|
(state, accountId) => state.getIn(['timelines', `account:${accountId}`, 'items'], ImmutableList()),
|
||||||
state => state.get('statuses'),
|
state => state.get('statuses'),
|
||||||
], (statusIds, 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 }) => ({
|
const mapStateToProps = (state, { accountId }) => ({
|
||||||
acct: state.getIn(['accounts', accountId, 'acct']),
|
acct: state.getIn(['accounts', accountId, 'acct']),
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import type { RecordOf } from 'immutable';
|
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';
|
import escapeTextContentForBrowser from 'escape-html';
|
||||||
|
|
||||||
|
@ -48,9 +48,9 @@ export interface AccountShape
|
||||||
extends Required<
|
extends Required<
|
||||||
Omit<ApiAccountJSON, 'emojis' | 'fields' | 'roles' | 'moved'>
|
Omit<ApiAccountJSON, 'emojis' | 'fields' | 'roles' | 'moved'>
|
||||||
> {
|
> {
|
||||||
emojis: List<CustomEmoji>;
|
emojis: ImmutableList<CustomEmoji>;
|
||||||
fields: List<AccountField>;
|
fields: ImmutableList<AccountField>;
|
||||||
roles: List<AccountRole>;
|
roles: ImmutableList<AccountRole>;
|
||||||
display_name_html: string;
|
display_name_html: string;
|
||||||
note_emojified: string;
|
note_emojified: string;
|
||||||
note_plain: string | null;
|
note_plain: string | null;
|
||||||
|
@ -70,8 +70,8 @@ export const accountDefaultValues: AccountShape = {
|
||||||
indexable: false,
|
indexable: false,
|
||||||
display_name: '',
|
display_name: '',
|
||||||
display_name_html: '',
|
display_name_html: '',
|
||||||
emojis: List<CustomEmoji>(),
|
emojis: ImmutableList<CustomEmoji>(),
|
||||||
fields: List<AccountField>(),
|
fields: ImmutableList<AccountField>(),
|
||||||
group: false,
|
group: false,
|
||||||
header: '',
|
header: '',
|
||||||
header_static: '',
|
header_static: '',
|
||||||
|
@ -82,7 +82,7 @@ export const accountDefaultValues: AccountShape = {
|
||||||
note: '',
|
note: '',
|
||||||
note_emojified: '',
|
note_emojified: '',
|
||||||
note_plain: 'string',
|
note_plain: 'string',
|
||||||
roles: List<AccountRole>(),
|
roles: ImmutableList<AccountRole>(),
|
||||||
uri: '',
|
uri: '',
|
||||||
url: '',
|
url: '',
|
||||||
username: '',
|
username: '',
|
||||||
|
@ -139,11 +139,15 @@ export function createAccountFromServerJSON(serverJSON: ApiAccountJSON) {
|
||||||
return AccountFactory({
|
return AccountFactory({
|
||||||
...accountJSON,
|
...accountJSON,
|
||||||
moved: moved?.id,
|
moved: moved?.id,
|
||||||
fields: List(
|
fields: ImmutableList(
|
||||||
serverJSON.fields.map((field) => createAccountField(field, emojiMap)),
|
serverJSON.fields.map((field) => createAccountField(field, emojiMap)),
|
||||||
),
|
),
|
||||||
emojis: List(serverJSON.emojis.map((emoji) => CustomEmojiFactory(emoji))),
|
emojis: ImmutableList(
|
||||||
roles: List(serverJSON.roles?.map((role) => AccountRoleFactory(role))),
|
serverJSON.emojis.map((emoji) => CustomEmojiFactory(emoji)),
|
||||||
|
),
|
||||||
|
roles: ImmutableList(
|
||||||
|
serverJSON.roles?.map((role) => AccountRoleFactory(role)),
|
||||||
|
),
|
||||||
display_name_html: emojify(
|
display_name_html: emojify(
|
||||||
escapeTextContentForBrowser(displayName),
|
escapeTextContentForBrowser(displayName),
|
||||||
emojiMap,
|
emojiMap,
|
||||||
|
|
|
@ -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 { SET_BROWSER_SUPPORT, SET_SUBSCRIPTION, CLEAR_SUBSCRIPTION, SET_ALERTS } from '../actions/push_notifications';
|
||||||
import { STORE_HYDRATE } from '../actions/store';
|
import { STORE_HYDRATE } from '../actions/store';
|
||||||
|
|
||||||
const initialState = Immutable.Map({
|
const initialState = ImmutableMap({
|
||||||
subscription: null,
|
subscription: null,
|
||||||
alerts: new Immutable.Map({
|
alerts: ImmutableMap({
|
||||||
follow: false,
|
follow: false,
|
||||||
follow_request: false,
|
follow_request: false,
|
||||||
favourite: false,
|
favourite: false,
|
||||||
|
@ -24,7 +24,7 @@ export default function push_subscriptions(state = initialState, action) {
|
||||||
|
|
||||||
if (push_subscription) {
|
if (push_subscription) {
|
||||||
return state
|
return state
|
||||||
.set('subscription', new Immutable.Map({
|
.set('subscription', ImmutableMap({
|
||||||
id: push_subscription.get('id'),
|
id: push_subscription.get('id'),
|
||||||
endpoint: push_subscription.get('endpoint'),
|
endpoint: push_subscription.get('endpoint'),
|
||||||
}))
|
}))
|
||||||
|
@ -36,11 +36,11 @@ export default function push_subscriptions(state = initialState, action) {
|
||||||
}
|
}
|
||||||
case SET_SUBSCRIPTION:
|
case SET_SUBSCRIPTION:
|
||||||
return state
|
return state
|
||||||
.set('subscription', new Immutable.Map({
|
.set('subscription', 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', 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 a new issue