feat: always shuffle suggestions

This commit is contained in:
Sean Yesmunt 2019-05-05 22:23:28 -04:00
parent 67f3a40913
commit 79d9f00cf2
4 changed files with 14 additions and 3 deletions

View file

@ -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 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)) - 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 ### Changed

View file

@ -1,14 +1,19 @@
// @flow // @flow
import React, { PureComponent } from 'react'; import React, { Component } from 'react';
import CategoryList from 'component/categoryList'; import CategoryList from 'component/categoryList';
import Spinner from 'component/spinner'; import Spinner from 'component/spinner';
type Props = { type Props = {
suggested: Array<{ label: string, uri: string }>, suggested: ?Array<{ label: string, uri: string }>,
loading: boolean, loading: boolean,
}; };
class SuggestedSubscriptions extends PureComponent<Props> { class SuggestedSubscriptions extends Component<Props> {
shouldComponentUpdate(nextProps: Props) {
const { suggested } = this.props;
return !suggested && !!nextProps.suggested;
}
render() { render() {
const { suggested, loading } = this.props; const { suggested, loading } = this.props;

View file

@ -9,6 +9,7 @@ import {
parseURI, parseURI,
} from 'lbry-redux'; } from 'lbry-redux';
import { swapKeyAndValue } from 'util/swap-json'; import { swapKeyAndValue } from 'util/swap-json';
import { shuffleArray } from 'util/shuffleArray';
// Returns the entire subscriptions state // Returns the entire subscriptions state
const selectState = state => state.subscriptions || {}; const selectState = state => state.subscriptions || {};
@ -90,6 +91,7 @@ export const selectSuggestedChannels = createSelector(
uri, uri,
label: suggestedChannels[uri], label: suggestedChannels[uri],
})) }))
.sort(shuffleArray)
.slice(0, 5); .slice(0, 5);
} }
); );

View file

@ -0,0 +1,3 @@
export function shuffleArray(array) {
return Math.round(Math.random()) - 0.5;
}