diff --git a/app/soapbox/features/follow_recommendations/index.js b/app/soapbox/features/follow_recommendations/index.js
index 129076666..58c6aa4d3 100644
--- a/app/soapbox/features/follow_recommendations/index.js
+++ b/app/soapbox/features/follow_recommendations/index.js
@@ -10,8 +10,8 @@ import Account from './components/account';
import Button from 'soapbox/components/button';
const mapStateToProps = state => ({
- suggestions: state.getIn(['suggestions_v2', 'items']),
- isLoading: state.getIn(['suggestions_v2', 'isLoading']),
+ suggestions: state.getIn(['suggestions', 'items']),
+ isLoading: state.getIn(['suggestions', 'isLoading']),
});
export default @connect(mapStateToProps)
diff --git a/app/soapbox/features/ui/components/who_to_follow_panel.js b/app/soapbox/features/ui/components/who_to_follow_panel.js
index 3013d3f80..31e87991d 100644
--- a/app/soapbox/features/ui/components/who_to_follow_panel.js
+++ b/app/soapbox/features/ui/components/who_to_follow_panel.js
@@ -43,10 +43,10 @@ class WhoToFollowPanel extends ImmutablePureComponent {
- {suggestions && suggestions.map(accountId => (
+ {suggestions && suggestions.map(suggestion => (
{
+ return {
+ source: 'past_interactions',
+ account: account.id,
+ };
+};
+
+const importAccounts = (state, accounts) => {
+ return state.withMutations(state => {
+ state.set('items', fromJS(accounts.map(accountToSuggestion)));
+ state.set('isLoading', false);
+ });
+};
+
+const importSuggestions = (state, suggestions) => {
+ return state.withMutations(state => {
+ state.set('items', fromJS(suggestions.map(x => ({ ...x, account: x.account.id }))));
+ state.set('isLoading', false);
+ });
+};
+
+const dismissAccount = (state, accountId) => {
+ return state.update('items', list => list.filterNot(x => x.account === accountId));
+};
+
+const dismissAccounts = (state, accountIds) => {
+ return state.update('items', list => list.filterNot(x => accountIds.includes(x.account)));
+};
+
export default function suggestionsReducer(state = initialState, action) {
switch(action.type) {
case SUGGESTIONS_FETCH_REQUEST:
+ case SUGGESTIONS_V2_FETCH_REQUEST:
return state.set('isLoading', true);
case SUGGESTIONS_FETCH_SUCCESS:
- return state.withMutations(map => {
- map.set('items', fromJS(action.accounts.map(x => x.id)));
- map.set('isLoading', false);
- });
+ return importAccounts(state, action.accounts);
+ case SUGGESTIONS_V2_FETCH_SUCCESS:
+ return importSuggestions(state, action.suggestions);
case SUGGESTIONS_FETCH_FAIL:
+ case SUGGESTIONS_V2_FETCH_FAIL:
return state.set('isLoading', false);
case SUGGESTIONS_DISMISS:
- return state.update('items', list => list.filterNot(id => id === action.id));
+ return dismissAccount(state, action.id);
+ case ACCOUNT_BLOCK_SUCCESS:
+ case ACCOUNT_MUTE_SUCCESS:
+ return dismissAccount(state, action.relationship.id);
+ case DOMAIN_BLOCK_SUCCESS:
+ return dismissAccounts(state, action.accounts);
default:
return state;
}
diff --git a/app/soapbox/reducers/suggestions_v2.js b/app/soapbox/reducers/suggestions_v2.js
deleted file mode 100644
index da06d4e1b..000000000
--- a/app/soapbox/reducers/suggestions_v2.js
+++ /dev/null
@@ -1,37 +0,0 @@
-import {
- SUGGESTIONS_V2_FETCH_REQUEST,
- SUGGESTIONS_V2_FETCH_SUCCESS,
- SUGGESTIONS_V2_FETCH_FAIL,
-} from '../actions/suggestions_v2';
-import { SUGGESTIONS_DISMISS } from '../actions/suggestions';
-import { ACCOUNT_BLOCK_SUCCESS, ACCOUNT_MUTE_SUCCESS } from 'soapbox/actions/accounts';
-import { DOMAIN_BLOCK_SUCCESS } from 'soapbox/actions/domain_blocks';
-import { Map as ImmutableMap, List as ImmutableList, fromJS } from 'immutable';
-
-const initialState = ImmutableMap({
- items: ImmutableList(),
- isLoading: false,
-});
-
-export default function suggestionsReducer(state = initialState, action) {
- switch(action.type) {
- case SUGGESTIONS_V2_FETCH_REQUEST:
- return state.set('isLoading', true);
- case SUGGESTIONS_V2_FETCH_SUCCESS:
- return state.withMutations(map => {
- map.set('items', fromJS(action.suggestions.map(x => ({ ...x, account: x.account.id }))));
- map.set('isLoading', false);
- });
- case SUGGESTIONS_V2_FETCH_FAIL:
- return state.set('isLoading', false);
- case SUGGESTIONS_DISMISS:
- return state.update('items', list => list.filterNot(x => x.account === action.id));
- case ACCOUNT_BLOCK_SUCCESS:
- case ACCOUNT_MUTE_SUCCESS:
- return state.update('items', list => list.filterNot(x => x.account === action.relationship.id));
- case DOMAIN_BLOCK_SUCCESS:
- return state.update('items', list => list.filterNot(x => action.accounts.includes(x.account)));
- default:
- return state;
- }
-}