Skip to content

Commit

Permalink
feat: always shuffle suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
Sean Yesmunt committed May 6, 2019
1 parent 67f3a40 commit 79d9f00
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
11 changes: 8 additions & 3 deletions src/ui/component/subscribeSuggested/view.jsx
Original file line number Diff line number Diff line change
@@ -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;

Expand Down
2 changes: 2 additions & 0 deletions src/ui/redux/selectors/subscriptions.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 || {};
Expand Down Expand Up @@ -90,6 +91,7 @@ export const selectSuggestedChannels = createSelector(
uri,
label: suggestedChannels[uri],
}))
.sort(shuffleArray)
.slice(0, 5);
}
);
Expand Down
3 changes: 3 additions & 0 deletions src/ui/util/shuffleArray.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export function shuffleArray(array) {
return Math.round(Math.random()) - 0.5;
}

0 comments on commit 79d9f00

Please sign in to comment.