gearheads
/
mastodon
Archived
2
0
Fork 0

Fix case-sensitive look-up for profiles in web UI (#19397)

gh/stable
Eugen Rochko 2022-10-21 10:06:03 +02:00 committed by GitHub
parent 23d367f544
commit 5e908c5a95
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 3 deletions

View File

@ -19,11 +19,12 @@ import { connectTimeline, disconnectTimeline } from 'mastodon/actions/timelines'
import LimitedAccountHint from './components/limited_account_hint'; import LimitedAccountHint from './components/limited_account_hint';
import { getAccountHidden } from 'mastodon/selectors'; import { getAccountHidden } from 'mastodon/selectors';
import { fetchFeaturedTags } from '../../actions/featured_tags'; import { fetchFeaturedTags } from '../../actions/featured_tags';
import { normalizeForLookup } from 'mastodon/reducers/accounts_map';
const emptyList = ImmutableList(); const emptyList = ImmutableList();
const mapStateToProps = (state, { params: { acct, id, tagged }, withReplies = false }) => { const mapStateToProps = (state, { params: { acct, id, tagged }, withReplies = false }) => {
const accountId = id || state.getIn(['accounts_map', acct]); const accountId = id || state.getIn(['accounts_map', normalizeForLookup(acct)]);
if (!accountId) { if (!accountId) {
return { return {

View File

@ -1,14 +1,16 @@
import { ACCOUNT_IMPORT, ACCOUNTS_IMPORT } from '../actions/importer'; import { ACCOUNT_IMPORT, ACCOUNTS_IMPORT } from '../actions/importer';
import { Map as ImmutableMap } from 'immutable'; import { Map as ImmutableMap } from 'immutable';
export const normalizeForLookup = str => str.toLowerCase();
const initialState = ImmutableMap(); const initialState = ImmutableMap();
export default function accountsMap(state = initialState, action) { export default function accountsMap(state = initialState, action) {
switch(action.type) { switch(action.type) {
case ACCOUNT_IMPORT: case ACCOUNT_IMPORT:
return state.set(action.account.acct, action.account.id); return state.set(normalizeForLookup(action.account.acct), action.account.id);
case ACCOUNTS_IMPORT: case ACCOUNTS_IMPORT:
return state.withMutations(map => action.accounts.forEach(account => map.set(account.acct, account.id))); return state.withMutations(map => action.accounts.forEach(account => map.set(normalizeForLookup(account.acct), account.id)));
default: default:
return state; return state;
} }