pl-fe: fix suggestions
Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
This commit is contained in:
@ -109,7 +109,7 @@ const FeedSuggestions: React.FC<IFeedSuggesetions> = ({ statusId, onMoveUp, onMo
|
||||
<CardBody>
|
||||
<HStack space={4} alignItems='center' className='overflow-x-auto md:space-x-0 lg:overflow-x-hidden'>
|
||||
{suggestedProfiles.slice(0, 4).map((suggestedProfile) => (
|
||||
<SuggestionItem key={suggestedProfile.account} accountId={suggestedProfile.account} />
|
||||
<SuggestionItem key={suggestedProfile.account_id} accountId={suggestedProfile.account_id} />
|
||||
))}
|
||||
</HStack>
|
||||
</CardBody>
|
||||
|
||||
@ -42,8 +42,8 @@ const FollowRecommendations: React.FC = () => {
|
||||
>
|
||||
{suggestions.map((suggestion) => (
|
||||
<AccountContainer
|
||||
key={suggestion.account}
|
||||
id={suggestion.account}
|
||||
key={suggestion.account_id}
|
||||
id={suggestion.account_id}
|
||||
withAccountNote
|
||||
/>
|
||||
))}
|
||||
|
||||
@ -129,7 +129,7 @@ const SearchResults = () => {
|
||||
if (results.accounts && results.accounts.size > 0) {
|
||||
searchResults = results.accounts.map(accountId => <AccountContainer key={accountId} id={accountId} />);
|
||||
} else if (!submitted && suggestions && !suggestions.isEmpty()) {
|
||||
searchResults = suggestions.map(suggestion => <AccountContainer key={suggestion.account} id={suggestion.account} />);
|
||||
searchResults = suggestions.map(suggestion => <AccountContainer key={suggestion.account_id} id={suggestion.account_id} />);
|
||||
} else if (loaded) {
|
||||
noResultsMessage = (
|
||||
<div className='empty-column-indicator'>
|
||||
|
||||
@ -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<Suggestion>(),
|
||||
items: ImmutableOrderedSet<MinifiedSuggestion>(),
|
||||
isLoading: false,
|
||||
});
|
||||
|
||||
type State = ReturnType<typeof ReducerRecord>;
|
||||
type Suggestion = ReturnType<typeof SuggestionRecord>;
|
||||
|
||||
const minifySuggestion = ({ account, ...suggestion }: SuggestionEntity) => ({
|
||||
...suggestion,
|
||||
account_id: account.id,
|
||||
});
|
||||
|
||||
type MinifiedSuggestion = ReturnType<typeof minifySuggestion>;
|
||||
|
||||
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) {
|
||||
|
||||
Reference in New Issue
Block a user