fix(linktree) : followers count gone

This commit is contained in:
2026-07-06 22:17:10 +07:00 Unverified
parent 6f45a3a5b7
commit 8a51dc9934
+17 -22
View File
@@ -1,4 +1,3 @@
import { unstable_cache } from "next/cache";
import { getYoutubeSubscriberCount } from "./youtube";
import { getRobloxFollowerCount } from "./roblox";
import { getDiscordMemberCount } from "./discord";
@@ -17,27 +16,23 @@ export interface FetchResult {
tiktokProfile: TiktokProfile;
}
const getFollowerCountsFromAPIs = unstable_cache(
async (): Promise<FetchResult> => {
const [youtube, roblox, discord, tiktokProfileResult] = await Promise.all([
getYoutubeSubscriberCount(),
getRobloxFollowerCount(),
getDiscordMemberCount(),
getTiktokProfile(),
]);
async function fetchFollowerCountsFromAPIs(): Promise<FetchResult> {
const [youtube, roblox, discord, tiktokProfileResult] = await Promise.all([
getYoutubeSubscriberCount(),
getRobloxFollowerCount(),
getDiscordMemberCount(),
getTiktokProfile(),
]);
const counts: FollowerCounts = {
youtube,
roblox,
discord,
tiktok: tiktokProfileResult.followerCount,
};
return { counts, tiktokProfile: tiktokProfileResult };
},
['follower-counts-api'],
{ revalidate: 3600, tags: ['follower-counts-api'] }
);
const counts: FollowerCounts = {
youtube,
roblox,
discord,
tiktok: tiktokProfileResult.followerCount,
};
return { counts, tiktokProfile: tiktokProfileResult };
}
export async function getFollowerCounts(): Promise<FetchResult> {
try {
@@ -57,7 +52,7 @@ export async function getFollowerCounts(): Promise<FetchResult> {
// Redis unavailable, fall through to fetch
}
const result = await getFollowerCountsFromAPIs();
const result = await fetchFollowerCountsFromAPIs();
try {
const { getRedisClient } = await import("@/lib/redis");