diff --git a/packages/pl-fe/src/features/feed-suggestions/feed-suggestions.tsx b/packages/pl-fe/src/features/feed-suggestions/feed-suggestions.tsx index c789c6126..3f3be0eb0 100644 --- a/packages/pl-fe/src/features/feed-suggestions/feed-suggestions.tsx +++ b/packages/pl-fe/src/features/feed-suggestions/feed-suggestions.tsx @@ -109,7 +109,7 @@ const FeedSuggestions: React.FC = ({ statusId, onMoveUp, onMo {suggestedProfiles.slice(0, 4).map((suggestedProfile) => ( - + ))} diff --git a/packages/pl-fe/src/features/follow-recommendations/index.tsx b/packages/pl-fe/src/features/follow-recommendations/index.tsx index 3d87c1121..e9598fd08 100644 --- a/packages/pl-fe/src/features/follow-recommendations/index.tsx +++ b/packages/pl-fe/src/features/follow-recommendations/index.tsx @@ -42,8 +42,8 @@ const FollowRecommendations: React.FC = () => { > {suggestions.map((suggestion) => ( ))} diff --git a/packages/pl-fe/src/features/search/components/search-results.tsx b/packages/pl-fe/src/features/search/components/search-results.tsx index bd696e8ad..3faf09db9 100644 --- a/packages/pl-fe/src/features/search/components/search-results.tsx +++ b/packages/pl-fe/src/features/search/components/search-results.tsx @@ -129,7 +129,7 @@ const SearchResults = () => { if (results.accounts && results.accounts.size > 0) { searchResults = results.accounts.map(accountId => ); } else if (!submitted && suggestions && !suggestions.isEmpty()) { - searchResults = suggestions.map(suggestion => ); + searchResults = suggestions.map(suggestion => ); } else if (loaded) { noResultsMessage = (
diff --git a/packages/pl-fe/src/reducers/suggestions.ts b/packages/pl-fe/src/reducers/suggestions.ts index 78b7dd50a..5f0e4d5c4 100644 --- a/packages/pl-fe/src/reducers/suggestions.ts +++ b/packages/pl-fe/src/reducers/suggestions.ts @@ -12,30 +12,31 @@ import { import type { Suggestion as SuggestionEntity } from 'pl-api'; import type { AnyAction } from 'redux'; -const SuggestionRecord = ImmutableRecord({ - source: '', - account: '', -}); - const ReducerRecord = ImmutableRecord({ - items: ImmutableOrderedSet(), + items: ImmutableOrderedSet(), isLoading: false, }); type State = ReturnType; -type Suggestion = ReturnType; + +const minifySuggestion = ({ account, ...suggestion }: SuggestionEntity) => ({ + ...suggestion, + account_id: account.id, +}); + +type MinifiedSuggestion = ReturnType; const importSuggestions = (state: State, suggestions: SuggestionEntity[]) => state.withMutations(state => { - state.update('items', items => items.concat(suggestions.map(x => ({ ...x, account: x.account.id })).map(suggestion => SuggestionRecord(suggestion)))); + state.update('items', items => items.concat(suggestions.map(minifySuggestion))); state.set('isLoading', false); }); const dismissAccount = (state: State, accountId: string) => - state.update('items', items => items.filterNot(item => item.account === accountId)); + state.update('items', items => items.filterNot(item => item.account_id === accountId)); const dismissAccounts = (state: State, accountIds: string[]) => - state.update('items', items => items.filterNot(item => accountIds.includes(item.account))); + state.update('items', items => items.filterNot(item => accountIds.includes(item.account_id))); const suggestionsReducer = (state: State = ReducerRecord(), action: AnyAction) => { switch (action.type) {