diff --git a/CHANGELOG.md b/CHANGELOG.md index 2a2b91056..10dcd8813 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - New routing setup to allow lbry.tv to use the browser url bar for navigation ([#2408](https://github.com/lbryio/lbry-desktop/pull/2408)) - New audio player ([#2406](https://github.com/lbryio/lbry-desktop/pull/2406)) +- Always show new suggested subscriptions ([#2541](https://github.com/lbryio/lbry-desktop/pull/2451)) ### Changed diff --git a/src/ui/component/subscribeSuggested/view.jsx b/src/ui/component/subscribeSuggested/view.jsx index ebc9269e8..cb27598d2 100644 --- a/src/ui/component/subscribeSuggested/view.jsx +++ b/src/ui/component/subscribeSuggested/view.jsx @@ -1,14 +1,19 @@ // @flow -import React, { PureComponent } from 'react'; +import React, { Component } from 'react'; import CategoryList from 'component/categoryList'; import Spinner from 'component/spinner'; type Props = { - suggested: Array<{ label: string, uri: string }>, + suggested: ?Array<{ label: string, uri: string }>, loading: boolean, }; -class SuggestedSubscriptions extends PureComponent { +class SuggestedSubscriptions extends Component { + shouldComponentUpdate(nextProps: Props) { + const { suggested } = this.props; + return !suggested && !!nextProps.suggested; + } + render() { const { suggested, loading } = this.props; diff --git a/src/ui/redux/selectors/subscriptions.js b/src/ui/redux/selectors/subscriptions.js index 97d39631f..2c3569a04 100644 --- a/src/ui/redux/selectors/subscriptions.js +++ b/src/ui/redux/selectors/subscriptions.js @@ -9,6 +9,7 @@ import { parseURI, } from 'lbry-redux'; import { swapKeyAndValue } from 'util/swap-json'; +import { shuffleArray } from 'util/shuffleArray'; // Returns the entire subscriptions state const selectState = state => state.subscriptions || {}; @@ -90,6 +91,7 @@ export const selectSuggestedChannels = createSelector( uri, label: suggestedChannels[uri], })) + .sort(shuffleArray) .slice(0, 5); } ); diff --git a/src/ui/util/shuffleArray.js b/src/ui/util/shuffleArray.js new file mode 100644 index 000000000..0cb632cad --- /dev/null +++ b/src/ui/util/shuffleArray.js @@ -0,0 +1,3 @@ +export function shuffleArray(array) { + return Math.round(Math.random()) - 0.5; +}