From 3383ef6318b280ad960c84c89a3dc56e06af9e39 Mon Sep 17 00:00:00 2001 From: Felix Ableitner Date: Tue, 19 Apr 2022 18:45:47 +0200 Subject: [PATCH] Shuffle instance recommendations into random order --- src/shared/components/instances.tsx | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/shared/components/instances.tsx b/src/shared/components/instances.tsx index 0cf302d..fe2db28 100644 --- a/src/shared/components/instances.tsx +++ b/src/shared/components/instances.tsx @@ -12,6 +12,13 @@ export class Instances extends Component { } 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 (
@@ -21,10 +28,7 @@ export class Instances extends Component { {this.header()}

- {this.renderList( - i18n.t("recommended_instances"), - instance_stats.recommended - )} + {this.renderList(i18n.t("recommended_instances"), recommended)} {this.renderList(i18n.t("popular_instances"), instance_stats.remaining)}
);