diff --git a/src/pages/playlist/[playlistId]/index.tsx b/src/pages/playlist/[playlistId]/index.tsx index f040378..0e0f15c 100644 --- a/src/pages/playlist/[playlistId]/index.tsx +++ b/src/pages/playlist/[playlistId]/index.tsx @@ -75,6 +75,7 @@ import { UNSORTED, } from "@/utils/comparators"; import createVideoSlug from "@/utils/createVideoSlug"; +import devLog from "@/utils/devLog"; import type { SharedPageProps } from "@/utils/getSharedPageProps"; import getSharedPageProps from "@/utils/getSharedPageProps"; import type { Comparator, RequiredNonNullable } from "@/utils/types"; @@ -163,10 +164,15 @@ function sortLinkedList(list: LinkedList) { const sortedList = []; while (next) { + delete lookUp[next.id]; sortedList.push(next); next = next.next ? lookUp[next.next.id] : undefined; } + if (sortedList.length !== list.length) { + devLog.error("The sorted linked list has a different size as the original list. It probably has broken links!"); + } + return sortedList; }