]> cat aescling's git repositories - mastodon.git/commitdiff
[Glitch] Add cold-start follow recommendations
authorEugen Rochko <eugen@zeonfederated.com>
Mon, 12 Apr 2021 10:37:14 +0000 (12:37 +0200)
committerClaire <claire.github-309c@sitedethib.com>
Wed, 21 Apr 2021 11:50:51 +0000 (13:50 +0200)
Port front-end changes from f7117646afddb2676e9275d8efe90c3a20c59021 to glitch-soc

Signed-off-by: Claire <claire.github-309c@sitedethib.com>
app/javascript/flavours/glitch/actions/suggestions.js
app/javascript/flavours/glitch/features/compose/components/search_results.js
app/javascript/flavours/glitch/reducers/suggestions.js

index 3687136ff48ac6b45f144bc981a5e740b4ade227..7e8f3713fd5450fc71b39ad5726e285f0ba94036 100644 (file)
@@ -11,8 +11,8 @@ export function fetchSuggestions() {
   return (dispatch, getState) => {
     dispatch(fetchSuggestionsRequest());
 
-    api(getState).get('/api/v1/suggestions').then(response => {
-      dispatch(importFetchedAccounts(response.data));
+    api(getState).get('/api/v2/suggestions').then(response => {
+      dispatch(importFetchedAccounts(response.data.map(x => x.account)));
       dispatch(fetchSuggestionsSuccess(response.data));
     }).catch(error => dispatch(fetchSuggestionsFail(error)));
   };
@@ -25,10 +25,10 @@ export function fetchSuggestionsRequest() {
   };
 };
 
-export function fetchSuggestionsSuccess(accounts) {
+export function fetchSuggestionsSuccess(suggestions) {
   return {
     type: SUGGESTIONS_FETCH_SUCCESS,
-    accounts,
+    suggestions,
     skipLoading: true,
   };
 };
index bbf997c1f0c76fb5582493cc29a500608786c50d..f5ec6587740b04f481bfc98fd2fc6e73c85e8b0d 100644 (file)
@@ -51,13 +51,13 @@ class SearchResults extends ImmutablePureComponent {
               <FormattedMessage id='suggestions.header' defaultMessage='You might be interested in…' />
             </div>
 
-            {suggestions && suggestions.map(accountId => (
+            {suggestions && suggestions.map(suggestion => (
               <AccountContainer
-                key={accountId}
-                id={accountId}
-                actionIcon='times'
-                actionTitle={intl.formatMessage(messages.dismissSuggestion)}
-                onActionClick={dismissSuggestion}
+                key={suggestion.get('account')}
+                id={suggestion.get('account')}
+                actionIcon={suggestion.get('source') === 'past_interaction' && 'times'}
+                actionTitle={suggestion.get('source') === 'past_interaction' && intl.formatMessage(messages.dismissSuggestion)}
+                onActionClick={suggestion.get('source') === 'past_interaction' && dismissSuggestion}
               />
             ))}
           </div>
index a08fedc25ca5084b89e0500b1da688b2cdcadc5d..2bc30d2c681e4f21b38367acdd38a7688ee25288 100644 (file)
@@ -19,18 +19,18 @@ export default function suggestionsReducer(state = initialState, action) {
     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('items', fromJS(action.suggestions.map(x => ({ ...x, account: x.account.id }))));
       map.set('isLoading', false);
     });
   case SUGGESTIONS_FETCH_FAIL:
     return state.set('isLoading', false);
   case SUGGESTIONS_DISMISS:
-    return state.update('items', list => list.filterNot(id => id === action.id));
+    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(id => id === action.relationship.id));
+    return state.update('items', list => list.filterNot(x => x.account === action.relationship.id));
   case DOMAIN_BLOCK_SUCCESS:
-    return state.update('items', list => list.filterNot(id => action.accounts.includes(id)));
+    return state.update('items', list => list.filterNot(x => action.accounts.includes(x.account)));
   default:
     return state;
   }