[Glitch] Profile editing: Fix regression with adding tags
Port 85fb9218a79955cc3d17229329a6b3ff9f6608ac to glitch-soc Signed-off-by: Claire <claire.github-309c@sitedethib.com>
This commit is contained in:
parent
bd18207c65
commit
631ec59f9c
@ -65,7 +65,7 @@ export const AccountEditTagSearch: FC = () => {
|
|||||||
value={query}
|
value={query}
|
||||||
onChange={handleSearchChange}
|
onChange={handleSearchChange}
|
||||||
placeholder={inputLabel}
|
placeholder={inputLabel}
|
||||||
items={suggestedTags as TagSearchResult[]}
|
items={suggestedTags}
|
||||||
isLoading={isLoading}
|
isLoading={isLoading}
|
||||||
renderItem={renderItem}
|
renderItem={renderItem}
|
||||||
onSelectItem={handleSelect}
|
onSelectItem={handleSelect}
|
||||||
|
|||||||
@ -14,20 +14,27 @@ import {
|
|||||||
fetchSuggestedTags,
|
fetchSuggestedTags,
|
||||||
addFeaturedTags,
|
addFeaturedTags,
|
||||||
} from '@/flavours/glitch/reducers/slices/profile_edit';
|
} from '@/flavours/glitch/reducers/slices/profile_edit';
|
||||||
import { useAppSelector, useAppDispatch } from '@/flavours/glitch/store';
|
import {
|
||||||
|
useAppSelector,
|
||||||
|
useAppDispatch,
|
||||||
|
createAppSelector,
|
||||||
|
} from '@/flavours/glitch/store';
|
||||||
|
|
||||||
import classes from './styles.module.scss';
|
import classes from './styles.module.scss';
|
||||||
|
|
||||||
const MAX_SUGGESTED_TAGS = 3;
|
const MAX_SUGGESTED_TAGS = 3;
|
||||||
|
|
||||||
|
const selectSuggestedTags = createAppSelector(
|
||||||
|
[(state) => state.profileEdit.tagSuggestions],
|
||||||
|
(tagSuggestions) => tagSuggestions?.slice(0, MAX_SUGGESTED_TAGS),
|
||||||
|
);
|
||||||
|
|
||||||
export const TagSuggestions: FC = () => {
|
export const TagSuggestions: FC = () => {
|
||||||
const { dismiss, wasDismissed } = useDismissible(
|
const { dismiss, wasDismissed } = useDismissible(
|
||||||
'profile/featured_tag_suggestions',
|
'profile/featured_tag_suggestions',
|
||||||
);
|
);
|
||||||
|
|
||||||
const suggestedTags = useAppSelector((state) =>
|
const suggestedTags = useAppSelector(selectSuggestedTags);
|
||||||
state.profileEdit.tagSuggestions?.slice(0, MAX_SUGGESTED_TAGS),
|
|
||||||
);
|
|
||||||
const existingTagCount = useAppSelector(
|
const existingTagCount = useAppSelector(
|
||||||
(state) => state.profileEdit.profile?.featuredTags.length,
|
(state) => state.profileEdit.profile?.featuredTags.length,
|
||||||
);
|
);
|
||||||
|
|||||||
@ -91,8 +91,8 @@ export function useSearchTags({
|
|||||||
// Add dedicated item for adding the current query
|
// Add dedicated item for adding the current query
|
||||||
const tags = useMemo(() => {
|
const tags = useMemo(() => {
|
||||||
const trimmedQuery = query ? trimHashFromStart(query.trim()) : '';
|
const trimmedQuery = query ? trimHashFromStart(query.trim()) : '';
|
||||||
if (!trimmedQuery || !fetchedTags.length) {
|
if (!trimmedQuery) {
|
||||||
return fetchedTags;
|
return fetchedTags as TagSearchResult[];
|
||||||
}
|
}
|
||||||
|
|
||||||
const results: TagSearchResult[] = [...fetchedTags]; // Make array mutable
|
const results: TagSearchResult[] = [...fetchedTags]; // Make array mutable
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user