mirror of
https://github.com/LemmyNet/joinlemmy-site.git
synced 2024-11-22 12:21:16 +00:00
Shuffle instance recommendations into random order (#101)
This commit is contained in:
parent
7c69d90981
commit
db0eabda95
1 changed files with 8 additions and 4 deletions
|
@ -12,6 +12,13 @@ export class Instances extends Component<any, any> {
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
// shuffle recommended instances list into random order
|
||||||
|
// https://stackoverflow.com/a/46545530
|
||||||
|
let recommended = instance_stats.recommended
|
||||||
|
.map(value => ({ value, sort: Math.random() }))
|
||||||
|
.sort((a, b) => a.sort - b.sort)
|
||||||
|
.map(({ value }) => value);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<Helmet title={title}>
|
<Helmet title={title}>
|
||||||
|
@ -21,10 +28,7 @@ export class Instances extends Component<any, any> {
|
||||||
{this.header()}
|
{this.header()}
|
||||||
<br />
|
<br />
|
||||||
<br />
|
<br />
|
||||||
{this.renderList(
|
{this.renderList(i18n.t("recommended_instances"), recommended)}
|
||||||
i18n.t("recommended_instances"),
|
|
||||||
instance_stats.recommended
|
|
||||||
)}
|
|
||||||
{this.renderList(i18n.t("popular_instances"), instance_stats.remaining)}
|
{this.renderList(i18n.t("popular_instances"), instance_stats.remaining)}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in a new issue