From ce8ce8dac142f1f79caf00a219bb8daeb03881e3 Mon Sep 17 00:00:00 2001 From: Echo Date: Mon, 13 Jul 2026 14:14:10 +0200 Subject: [PATCH] Fix account language selector (#39801) --- .../subscribed_languages_modal/index.jsx | 16 ++++++++++------ app/javascript/mastodon/selectors/timelines.ts | 6 ++++++ 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/app/javascript/mastodon/features/subscribed_languages_modal/index.jsx b/app/javascript/mastodon/features/subscribed_languages_modal/index.jsx index 8d5665b1c47..31e4a2a99c3 100644 --- a/app/javascript/mastodon/features/subscribed_languages_modal/index.jsx +++ b/app/javascript/mastodon/features/subscribed_languages_modal/index.jsx @@ -15,16 +15,21 @@ import { IconButton } from 'mastodon/components/icon_button'; import { injectIntl } from '@/mastodon/components/intl'; import Option from 'mastodon/features/report/components/option'; import { languages as preloadedLanguages } from 'mastodon/initial_state'; +import { selectTimelinesByAccount } from '@/mastodon/selectors/timelines'; const messages = defineMessages({ close: { id: 'lightbox.close', defaultMessage: 'Close' }, }); -const getAccountLanguages = createSelector([ - (state, accountId) => state.getIn(['timelines', `account:${accountId}`, 'items'], ImmutableList()), - state => state.get('statuses'), -], (statusIds, statuses) => - ImmutableSet(statusIds.map(statusId => statuses.get(statusId)).filter(status => !status.get('reblog')).map(status => status.get('language')))); +const getAccountLanguages = createSelector( + [selectTimelinesByAccount, (state) => state.get('statuses')], + (timelines, statuses) => ImmutableSet( + timelines + .reduce((statusIds, timeline) => statusIds.concat(timeline.get('items')), ImmutableList()) + .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']), @@ -37,7 +42,6 @@ const mapDispatchToProps = (dispatch, { accountId }) => ({ onSubmit (languages) { dispatch(followAccount(accountId, { languages })); }, - }); class SubscribedLanguagesModal extends ImmutablePureComponent { diff --git a/app/javascript/mastodon/selectors/timelines.ts b/app/javascript/mastodon/selectors/timelines.ts index af1a4ebb21f..7f6b9ecb493 100644 --- a/app/javascript/mastodon/selectors/timelines.ts +++ b/app/javascript/mastodon/selectors/timelines.ts @@ -32,6 +32,12 @@ export const selectTimelineByParams = createAppSelector( (key, timelines) => toTypedTimeline(timelines.get(key)), ); +export const selectTimelinesByAccount = createAppSelector( + [(state) => state.timelines, (_, accountId: string) => accountId], + (timelines, accountId) => + timelines.filter((_, key) => key.startsWith(`account:${accountId}:`)), +); + export function toTypedTimeline(timeline?: ImmutableMap) { if (!timeline) { return null;