[Glitch] Fix account language selector

Port 78894ca4ad00b52848ed89c32dc33c6d2663c681 to glitch-soc

Signed-off-by: Claire <claire.github-309c@sitedethib.com>
This commit is contained in:
Echo 2026-07-13 14:14:10 +02:00 committed by Tarrien
parent d3c3e5d12a
commit 9517037d46
2 changed files with 16 additions and 6 deletions

View File

@ -15,16 +15,21 @@ import { IconButton } from 'flavours/glitch/components/icon_button';
import { injectIntl } from '@/flavours/glitch/components/intl'; import { injectIntl } from '@/flavours/glitch/components/intl';
import Option from 'flavours/glitch/features/report/components/option'; import Option from 'flavours/glitch/features/report/components/option';
import { languages as preloadedLanguages } from 'flavours/glitch/initial_state'; import { languages as preloadedLanguages } from 'flavours/glitch/initial_state';
import { selectTimelinesByAccount } from '@/flavours/glitch/selectors/timelines';
const messages = defineMessages({ const messages = defineMessages({
close: { id: 'lightbox.close', defaultMessage: 'Close' }, close: { id: 'lightbox.close', defaultMessage: 'Close' },
}); });
const getAccountLanguages = createSelector([ const getAccountLanguages = createSelector(
(state, accountId) => state.getIn(['timelines', `account:${accountId}`, 'items'], ImmutableList()), [selectTimelinesByAccount, (state) => state.get('statuses')],
state => state.get('statuses'), (timelines, statuses) => ImmutableSet(
], (statusIds, statuses) => timelines
ImmutableSet(statusIds.map(statusId => statuses.get(statusId)).filter(status => !status.get('reblog')).map(status => status.get('language')))); .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 }) => ({ const mapStateToProps = (state, { accountId }) => ({
acct: state.getIn(['accounts', accountId, 'acct']), acct: state.getIn(['accounts', accountId, 'acct']),
@ -37,7 +42,6 @@ const mapDispatchToProps = (dispatch, { accountId }) => ({
onSubmit (languages) { onSubmit (languages) {
dispatch(followAccount(accountId, { languages })); dispatch(followAccount(accountId, { languages }));
}, },
}); });
class SubscribedLanguagesModal extends ImmutablePureComponent { class SubscribedLanguagesModal extends ImmutablePureComponent {

View File

@ -32,6 +32,12 @@ export const selectTimelineByParams = createAppSelector(
(key, timelines) => toTypedTimeline(timelines.get(key)), (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<string, unknown>) { export function toTypedTimeline(timeline?: ImmutableMap<string, unknown>) {
if (!timeline) { if (!timeline) {
return null; return null;