about summary refs log tree commit diff
path: root/app/javascript/flavours/glitch/features/explore/suggestions.js
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2022-02-25 00:34:33 +0100
committerClaire <claire.github-309c@sitedethib.com>2022-10-08 20:49:02 +0200
commit058b74dc0a3cdf6873117ea9f48351035b365d7f (patch)
tree210be08427b9e96162f21ab77dbfe0c1233978ef /app/javascript/flavours/glitch/features/explore/suggestions.js
parent870f0aae482f2aa8ce44c29acdbea7ded4655463 (diff)
[Glitch] Add explore page to web UI
Port d4592bbfcd091c4eaef8c8f24c47d5c2ce1bacd3 to glitch-soc

Signed-off-by: Claire <claire.github-309c@sitedethib.com>
Diffstat (limited to 'app/javascript/flavours/glitch/features/explore/suggestions.js')
-rw-r--r--app/javascript/flavours/glitch/features/explore/suggestions.js40
1 files changed, 40 insertions, 0 deletions
diff --git a/app/javascript/flavours/glitch/features/explore/suggestions.js b/app/javascript/flavours/glitch/features/explore/suggestions.js
new file mode 100644
index 000000000..9dbf49b4f
--- /dev/null
+++ b/app/javascript/flavours/glitch/features/explore/suggestions.js
@@ -0,0 +1,40 @@
+import React from 'react';
+import PropTypes from 'prop-types';
+import ImmutablePropTypes from 'react-immutable-proptypes';
+import Account from 'flavours/glitch/containers/account_container';
+import LoadingIndicator from 'flavours/glitch/components/loading_indicator';
+import { connect } from 'react-redux';
+import { fetchSuggestions } from 'flavours/glitch/actions/suggestions';
+
+const mapStateToProps = state => ({
+  suggestions: state.getIn(['suggestions', 'items']),
+  isLoading: state.getIn(['suggestions', 'isLoading']),
+});
+
+export default @connect(mapStateToProps)
+class Suggestions extends React.PureComponent {
+
+  static propTypes = {
+    isLoading: PropTypes.bool,
+    suggestions: ImmutablePropTypes.list,
+    dispatch: PropTypes.func.isRequired,
+  };
+
+  componentDidMount () {
+    const { dispatch } = this.props;
+    dispatch(fetchSuggestions(true));
+  }
+
+  render () {
+    const { isLoading, suggestions } = this.props;
+
+    return (
+      <div className='explore__links'>
+        {isLoading ? (<LoadingIndicator />) : suggestions.map(suggestion => (
+          <Account key={suggestion.get('account')} id={suggestion.get('account')} />
+        ))}
+      </div>
+    );
+  }
+
+}