feat: always shuffle suggestions
This commit is contained in:
parent
67f3a40913
commit
79d9f00cf2
4 changed files with 14 additions and 3 deletions
|
@ -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
|
||||
|
||||
|
|
|
@ -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<Props> {
|
||||
class SuggestedSubscriptions extends Component<Props> {
|
||||
shouldComponentUpdate(nextProps: Props) {
|
||||
const { suggested } = this.props;
|
||||
return !suggested && !!nextProps.suggested;
|
||||
}
|
||||
|
||||
render() {
|
||||
const { suggested, loading } = this.props;
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
);
|
||||
|
|
3
src/ui/util/shuffleArray.js
Normal file
3
src/ui/util/shuffleArray.js
Normal file
|
@ -0,0 +1,3 @@
|
|||
export function shuffleArray(array) {
|
||||
return Math.round(Math.random()) - 0.5;
|
||||
}
|
Loading…
Reference in a new issue