Skip to content

Commit

Permalink
fix: buidl time
Browse files Browse the repository at this point in the history
  • Loading branch information
Dovakiin0 committed Nov 19, 2024
1 parent 8cc27d2 commit 60ca91a
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions src/utils/fallback-server.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,23 @@
export function getFallbackServer(serversData: any): {
import { IEpisodeServers } from "@/types/episodes";

export function getFallbackServer(serversData: IEpisodeServers | undefined): {
serverName: string;
key: string;
} {
const keys = ["sub", "dub", "raw"];
for (const key of keys) {
if (serversData?.[key]?.[0]?.serverName) {
return {
serverName: serversData[key][0].serverName,
key,
};
if (serversData) {
const keys: Array<"sub" | "dub" | "raw"> = ["sub", "dub", "raw"]; // Only valid keys
for (const key of keys) {
const serverList = serversData[key]; // Safely index the object
if (serverList && serverList[0]?.serverName) {
return {
serverName: serverList[0].serverName,
key,
};
}
}
}
return {
serverName: "",
key: "",
}; // No valid server found
}; // Fallback if no valid server is found
}

0 comments on commit 60ca91a

Please sign in to comment.