From c6446801738b52b49d800d101238a017ff82c137 Mon Sep 17 00:00:00 2001 From: Samarth Goyal <95200941+Samarth827@users.noreply.github.com> Date: Fri, 6 Dec 2024 00:32:04 +0530 Subject: [PATCH] Filtered the model list to remove duplicate IDs temporary fix; The names and other properties could be different, but the requests are routed purely on the basis of the model ID, which had duplicate IDs for variants. A permanent fix is called for to have unique IDs for all variants. Filtering also provides a better experience for the demo by removing redundancy. --- lib/hooks/use-models.tsx | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/hooks/use-models.tsx b/lib/hooks/use-models.tsx index e86c5e3..e93a341 100644 --- a/lib/hooks/use-models.tsx +++ b/lib/hooks/use-models.tsx @@ -31,7 +31,14 @@ export function useModels() { return { models: - data?.data.slice().sort((a, b) => a.name.localeCompare(b.name)) ?? [], + data?.data + .slice() + .sort( + (a, b) => a.id.localeCompare(b.id) || a.name.length - b.name.length + ) + .filter( + (item, index, array) => index === 0 || item.id !== array[index - 1].id + ) ?? [], isLoading, error }