[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}
|
||||
onChange={handleSearchChange}
|
||||
placeholder={inputLabel}
|
||||
items={suggestedTags as TagSearchResult[]}
|
||||
items={suggestedTags}
|
||||
isLoading={isLoading}
|
||||
renderItem={renderItem}
|
||||
onSelectItem={handleSelect}
|
||||
|
||||
@ -14,20 +14,27 @@ import {
|
||||
fetchSuggestedTags,
|
||||
addFeaturedTags,
|
||||
} 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';
|
||||
|
||||
const MAX_SUGGESTED_TAGS = 3;
|
||||
|
||||
const selectSuggestedTags = createAppSelector(
|
||||
[(state) => state.profileEdit.tagSuggestions],
|
||||
(tagSuggestions) => tagSuggestions?.slice(0, MAX_SUGGESTED_TAGS),
|
||||
);
|
||||
|
||||
export const TagSuggestions: FC = () => {
|
||||
const { dismiss, wasDismissed } = useDismissible(
|
||||
'profile/featured_tag_suggestions',
|
||||
);
|
||||
|
||||
const suggestedTags = useAppSelector((state) =>
|
||||
state.profileEdit.tagSuggestions?.slice(0, MAX_SUGGESTED_TAGS),
|
||||
);
|
||||
const suggestedTags = useAppSelector(selectSuggestedTags);
|
||||
const existingTagCount = useAppSelector(
|
||||
(state) => state.profileEdit.profile?.featuredTags.length,
|
||||
);
|
||||
|
||||
@ -91,8 +91,8 @@ export function useSearchTags({
|
||||
// Add dedicated item for adding the current query
|
||||
const tags = useMemo(() => {
|
||||
const trimmedQuery = query ? trimHashFromStart(query.trim()) : '';
|
||||
if (!trimmedQuery || !fetchedTags.length) {
|
||||
return fetchedTags;
|
||||
if (!trimmedQuery) {
|
||||
return fetchedTags as TagSearchResult[];
|
||||
}
|
||||
|
||||
const results: TagSearchResult[] = [...fetchedTags]; // Make array mutable
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user